x cd /pub/data/pl9490/Tools; %let pgm=pl94trend_90geog_US; filename pgm "&pgm..sas"; *---This setup will generate sas datasets in the pl9490tx subdirectory of pl9490 for varying states. These sets are suitable for use as input to the pl94 trend reports that allow juxtaposing basic pl94 pop data for 1990 and 2000. This setup generates data BASED ON 1990 STF1C (national data). Because we do not have a national pl94 file for 1990, we use stf901 as an laternative source. Confusing because we store the result in a pl9490tx dir. jgb, 4-13-01. Rerun 5-14-01 to get msa data. ---*; *libname pl9490 '/pub/data/pl9490' access=readonly; libname stf901 '/pub/data/stf901'; libname pl9490tx '/pub/data/pl9490/pl9490tx'; *--------Generate data for US states, usregdiv, counties and places from the "STF1C" data set--; data pl9490tx.usregdiv pl9490tx.usstates pl9490tx.uscntys pl9490tx.usplaces pl9490tx.usmetros; set stf901.us; where slvl in ('010','020','030','040','050','161','300','301','310','311'); if geocomp='00'; *--borrow code from that used to create the 2k pl94 data sets--; length default=5; SumLev=slvl; *--Same item, new name--; length geocode $12; select(SumLev); *---Assign the standardized Geographic Code to uniquely ID the geographic area--; when('010') geocode='us'; when('020') geocode='r'||reg; when('030') geocode='d'||div; when('040') geocode=state; when('050') geocode=county; when('161') geocode=%concatd(state,placefp); when('300') geocode=msacmsa; when('301') geocode=pmsa; when('310') geocode=%concatd(msacmsa,state); when('311') geocode=%concatd(pmsa,state); otherwise do; put '****Unexpected SumLev code encountered: No value assigned to geocode: ' SumLev= areaname=; abort 500; end; end; *--select group--; if index(geocode,'####') then delete; *--some metro area summaries in New England have this---; if SumLev='310' then Areaname=stab||'/'||put(msacmsa,$metro.); else if SumLev='311' then Areaname=stab||'/'||put(pmsa,$metro.); *--assign all the vars to corresponding names used in the pl94-2000 mosums data set(s)--; totpop=p1i1; white1=p6i1; black1=p6i2; indian1=p6i3; asianpi=p6i4; *--NOT the same as a 1990 category-; other1=p6i5; array p12 (5,2,31) p12i1-p12i310; *--Table p12 is race(5) by sex(2) by age(31). We need to aggregate it to get persons over 18 by race--; array ovr18(5) whovr181 blovr181 inovr181 aspovr18 otovr181; array p6(5) p6i1-p6i5; array p13(2,31) p13i1-p13i62; *--hispanic persons by sex(2) and age(31)--; _sumh=0; do _i=1 to 5; _sum=0; do _sex=1 to 2; do _age=1 to 12; _sum + p12(_i,_sex,_age); if _i=1 then _sumh + p13(_sex,_age); *-- do not want to count hispanics more than once; end; end; ovr18(_i)= p6(_i) - _sum; *--subtract the under-17 for the race from the total pop for the race to get over18; end; *--_i loop --; drop _i _sex _age _sum _sumh; over18=sum(of whovr181 -- otovr181); hisppop=p8i1; whitenh1=p10i1; hisovr18=hisppop - _sumh; *--we summed the hispanic pop under 17 in the do loops above - from table p13-; *--stf1 does not give us the count of non-white hispanics over 18. So we estimate by taking the ratio of white non-hispanic to total whites and applying this to the total whites over 18. So if 70 pct of the total white pop is non-hsipanic then we estimate that the same pct of whites over 18 are non-hispanic.--; if white1 then wnovr181=(whitenh1/white1) * whovr181; else wnovr181=0; *---Using the 3 states where we have the white non-hispanic over 18 numbers from pl94 (Il, ks and mo) we ran a test to see how this estimate compared with the true value. Based on that 3-state sample we adjust our estimate by the factor 1.0049 ratio that we found for those 3 states combined.----; wnovr181=round( 1.0049*wnovr181 ); label wnovr181='White Non-Hispanic Over 18 (est)'; select(sumlev); when('010','020','030') output pl9490tx.usregdiv; when('040') output pl9490tx.usstates; when('050') output pl9490tx.uscntys; when('161') output pl9490tx.usplaces; when('300','301','310','311') output pl9490tx.usmetros; otherwise do; put //'***Logic Error - Unexpected sumlev value: ' /_all_; abort 700; end; end; *---select---; label totpop='1990 complete count pop'; keep areaname state county sumlev reg div geocode totpop -- wnovr181; *--only keep mostly the new variable (names)--; rename reg=Region div=Division; run;