x cd /pub/data/acs2008/Tools; %let pgm=wic_eligible_tots; filename pgm "&pgm..sas"; *----Apply a CPR-like algorithm using data from detailed table b17024 (age by poverty ratio) to get estimate counts by Mo counties of persons aged 0-4 who are below 185% of the poverty level. For the Mo Hunger Atlas folks, Jill Lucht contact person. (The 185% of p.r. makes them WIC eligible and being aged 0-4 makes them tots. Hence the pgm name. ) J. Blodgett. 4/2010. ----*; %let acsyear=2008; *<---the acs vintage data year. The 2008 vintage data were released in 2009 and as of early 2010 are still the most current estimates.----; %let acsyr=%substr(&acsyear,3,2); %let acsyearm2=%eval(&Acsyear-2); %let acsyrm2=%substr(&acsyearm2,3,2); %let years=%str(&acsyearm2.-&acsyear); %libname(acspums); libname acsbtabs "/pub/data/acs&acsyear./basetbls"; libname acs2008 '/pub/data/acs2008' access=readonly; libname corrlst "/pub/data/corrlst"; libname cprdata "/pub/data/acs&acsyear./cprdata"; libname user '/SAS_temp/userb'; *----Step 1: Access the PUMS data to get fudge factors at state and PUMA level. We use these factors to convert data for 0-5, <=185 to 0-4, <=185 for the state and use it to adjust data for counties with acs data. We also calculate the percent of persons 0-4 who are <= 185 by PUMA and we shall apply those ratios to the latest county pop estimates by age to get estimated <=185 for tots data. ----; /* ========================begin comment==================================== data aggin; set acspums.moprecs083yr(keep=agep povpip pwgtp puma ); where agep <=5; *---Keep only records for persons age 0-5---; if agep <=4 then do; age0_4=pwgtp; if povpip<=185 then Age0_4Under185=pwgtp; else Age0_4Under185=0; end; else age0_4=0; age0_5=pwgtp; if povpip<=185 then Age0_5Under185=pwgtp; else Age0_5Under185=0; drop agep povpip pwgtp; run; proc summary data=aggin; class puma; var _numeric_; output out=aggout sum=; run; data fudgefacts_wic(label='From wic_eligible_tots'); set aggout; if _type_=0 then do; *---Statewide. We use a fudge factor called F2 that we shall apply to all counties that have a table b17024. It is used to "factor down" the 0-5 poor tots to get just 0-4 poor tots. It is a simple ratio, calculated as follows.... ; F2=Age0_4Under185/Age0_5Under185; format f2 5.3; end; else F1=Age0_4Under185/age0_4; *<---pct of tots wic-eligible by PUMA. --; *drop _: ; run; proc print; run; data _null_; set fudgefacts_wic(obs=1); call symput('f2',put(f2,7.5)); stop; run; %put f2=&f2; *---Pull the ACS data from the latest 3-year period. Get the count of 0-5, under 185 from b17024. We need to factor down these counts to estimate the 0-4, under 185 wich we do by matching with a PUMA and using the F1 factor derived above from PUMS data-; data b17extract; length County $5; set acsbtabs.ustabs17_203yr(keep=geoid state b17024i3-b17024i9); where state='29' and geoid=:'05000'; county=substr(geoid,8,5); Age0_5Under185=sum(of b17024i3-b17024i9); Age0_4Under185=Age0_5Under185* &f2; *---overall factor for state----; format Age0_4Under185 comma9.; if age0_4Under185=. then put '****** Missing data **** ' _all_; drop b17: geoid; run; proc print data=b17extract; run; *---Now do the remaining counties by getting their latest estimated 0-4 pops and applying a PUMA-based ratio to estimate under 185 portion---; ==========================end comment====================================== */ data smallcoests; merge cprdata.moagedata06_08(keep=county age0_4 in=inagedata) cprdata.mocnty_puma08(keep=county puma5 size); by county; if size='s'; run; proc sort; by puma5; run; data smallcoests2; merge smallcoests(in=insmall) fudgefacts_wic(firstobs=2 keep=puma f1 rename=(puma=puma5) in=inff); by puma5; if insmall; Age0_4Under185=age0_4*f1; format Age0_4Under185 comma9.; label age0_4Under185='Kids aged 0-4 Under 185% of Povertry Level'; run; proc sort; by county; run; proc print data=smallcoests2; title 'smallcoests2'; data cprdata.&pgm; set smallcoests2 b17extract; by county; run; ods html file ="/pub/reports/temp/&pgm..html" style=osedablue; proc print data=cprdata.&pgm label uniform; title2 "&pgm"; sum age0_4Under185; format county $mocnty.; run; ods html close;