x cd /pub/data/sf12000/Tools; %let pgm=agersexh_agg; filename pgm "&pgm..sas"; /*--This program aggregates data in the special agersexh data set for MO to satisfy the following request from Mo Dept of Health via Debbie: public access. " ...I just tried to run the P12A-P12H tables from the moph sf1 file on Uexplore, but it won't fully load (probably because of size). Could you run a file (in comma-separated format or already in Excel) for Stan Cowan at MO Dept. of Health? He needs Missouri county population by age and race. He would like to have the number of people (by county) in age categories listed below, also broken down by race. He'd like Hispanic by age, too, but not broken down by race. Here are the age categories: age 0-39, age 40 and over age 50 and over age 60 and over age 70 and over age 80 and over Debbie " Strategy for handling this is simple: 1. Code a data step where we create 6 variables corresponding to the 6 requested age categories. 2. Use proc means to aggregate the 6 variables. --- */ %libname (sf12000); filename dlmout '/SAS_temp/mocoagerh.csv'; libname user '/SAS_temp/user'; *filename pcpgm 'l:\SAS Tools\samppgms\sf1_agersexh_agg.sas'; /*<=========================Comment out===================================== *---create temporary data set with the six age counts. Create new category variable racehisp---; data aggin; set sf12000.moagersexh; *<---use the "ng" version since we do not need the geocodes. We just need a summary for the entire state.--; where race ne ' '; *<---filter out those obs without race and hispanic detail--; fipco=county; *<---fipco will be the code and county will be the name of the county-; if age <40 then under40=persons; else over40 = persons; if age > 50 then over50 = persons; if age > 60 then over60 = persons; if age > 70 then over70 = persons; if age > 80 then over80=persons; racehisp=race; output; *--always output an obs with the race category-; if hispanic='1' then do; racehisp='hi'; output; *--only output with the "hi"(spanic) value if the hispanic category var indicates that these persons are hispanic.--; end; keep fipco county racehisp persons under40--over80; *<---note the "--" variable interval. These are all the new variables being created in the data step-; run; *--this step processed over 900,000 observations and took appx. 51 seconds to run.--; proc sort; by county racehisp; run; *--and now let proc means do the arithmetic for us--; title 'Persons in Selected Age Groups, State of Missouri'; title2 'Source: Summary File 1, 2000 Census (sf12000.agersexh)'; footnote 'Programming by the Office of Social and Economic Data Analysis'; options nodate linesize=100 pageno=1; %agg(aggin=aggin,aggout=aggout, aggby=county racehisp, idvars=fipco, aggvars=under40 over40 over50 over60 over70 over80, dropvars=_lvl_ _nag_) run; data aggout; set aggout; array counts under40--over80; do over counts; if counts=. then counts=0; end; format county $mocnty.; run; ===========================End commented out================================ */ proc print data=aggout(obs=100); title2 'Sample Obs on aggout'; run; %cnvtdlm(setin=aggout,names=1)