x cd /pub/data/sf12000/Tools; %let pgm=mo_urbanrural_age; filename pgm "&pgm..sas"; /*--This program aggregates data by age for urban/rural categories. We use block level data merged with the mable2k data to attach urban/rural categories. Per request from Debbie Pitts 6-02. --*/ %libname (sf12000); %libname (mable2k); libname user '/SAS_temp/user'; options msglevel=i; ods printer pdf file="/pub/reports/&pgm..pdf"; title "Missouri Urban and Rural Population by Age"; options nodate; footnote "Run on &sysdate From Setup in sf12000/Tools/&pgm..sas"; footnote2 "Source: 2000 Summary File 1, Tables P12 and P14, and mable2k Database for Urban/Rural Values"; /*<=========================Comment out===================================== proc sort data = sf12000.mophblks(keep=county tract block p12i1-p12i49 p14i1-p14i43) out=sf1blks force; by county tract block; run; data p14u p14r p12u p12r; merge sf1blks(in=insf1) mable2k.moblks2(in=inmable keep=county tract block ur); by county tract block; if not (inmable and insf1) then do; put '***data missing***' insf1= inmable= county= tract= block=; nbad+1; if nbad ge 100 then abort; delete; end; array p12(2,3:25) p12i3-p12i25 p12i27-p12i49; array p14(2,0:19) p14i3-p14i22 p14i24-p14i43; do Age= 3 to 25; Count=p12(1,age) + p12(2,age); if count then if ur='U' then output p12u; else output p12r; end; do age=0 to 19; Count=p14(1,age) + p14(2,age); if count then if ur='U' then output p14u; else output p14r; end; run; ===========================End commented out================================ */ data p12; set p12r p12u; run; data p14; set p14r p14u; run; proc format; value agecat 3='Under 5 Yrs' 4='5 to 9' 5='10 to 14' 6='15 to 17' 7='18 and 19' 8='20' 9='21' 10='22 to 24' 11='25 to 29' 12='30 to 34' 13='35 to 39' 14='40 to 44' 15='45 to 49' 16='50 to 54' 17='55 to 59' 18='60 and 61' 19='62 to 64' 20='65 and 66' 21='67 to 69' 22='70 to 74' 23='75 to 79' 24='80 to 84' 25='85 and over'; value $ur 'U'='Urban' 'R'='Rural'; value age 0='Under 1 year' 1='1 year old'; run; proc freq data=p12; by ur; weight count; format ur $ur.; table age; format age agecat.; title2 'All Ages -- From SF1 Table 12'; run; proc freq data=p14; by ur; weight count; format ur $ur.; table age; title2 'Ages 0 to 19 -- From SF1 Table 14'; run;