x cd /pub/data/popests/Tools; %let pgm=stateasrh_cnvt20yy; filename pgm "&pgm..sas"; *--Convert state level age-sex-race-hispanic origin pop estimates (single years of age). John Blodgett, OSEDA, U of Mo Outreach & Extension Under contract with the Missouri Census Data Center 9/03 --*; /* Update History Sep. 22, 2003: Begin work. */ %let temp=; ***temp; *<====change to null value when data is no longer embargoed and is moved to popests directory--; %let year=2002; %let yr=%substr(&year,3,2); libname popests "/pub/data/popests/&temp"; filename in5 '/pub/data/popests/usstatearsh5.txt'; filename in6 '/pub/data/popests/usstatearsh6.txt'; %macro doit; data popests.usstateasrh5_&yr(label="US State pop ests by single yrs age, race (Alone or in comb), sex, hispanic"); infile in5 ; length state $2 sex hispanic race $1 age 3 popest_cen2k popest_base2k %do _year=2000 %to &year; popest_&_year %end; 4; input state -- popest_&year; label popest_cen2k='Census 2000 Pop' popest_base2k='4-1-2000 Pop Estimates Base' %do _year=2000 %to &year; popest_&_year="July 1, &year Pop Estimate" %end; ; run; data popests.usstateasrh6_&yr(label="US State pop ests by single yrs age, race (alone or multi), sex, hispanic"); infile in6 ; length state $2 sex hispanic race $1 age 3 popest_cen2k popest_base2k %do _year=2000 %to &year; popest_&_year %end; 4; input state -- popest_&year; label popest_cen2k='Census 2000 Pop' popest_base2k='4-1-2000 Pop Estimates Base' %do _year=2000 %to &year; popest_&_year="July 1, &_year Pop Estimate" %end; ; run; %mend doit; options mprint; %doit ; *---create the Missouri subset views of the 2 national datasets----; proc sql; create view popests.mostateasrh5_&yr as select * from popests.usstateasrh5_&yr where state='29'; create view popests.mostateasrh6_&yr as select * from popests.usstateasrh6_&yr where state='29'; quit; *-----Part 2: Do a proc tabulate report-----; proc format; value age 0-4=' 0 to 4' 5-13=' 5 to 13' 14-17='14 to 17' 18-24='18 to 24' 25-64='25 to 64' 65-high='65 +'; value $sex 1='Male' 2='Female'; run; proc tabulate data=popests.mostateasrh6_&yr; class age sex ; format age age. sex $sex. state $state.; var popest_cen2k popest_2002 popest_base2k; by state; table all age,(popest_&year)*(all='Total' sex)*(sum=' '*f=comma11. ); title2 'Tabular Report by State: Age by Sex Detail'; run;