x cd /pub/data/popests/Tools; %let pgm=application_ageracesexmetro; filename pgm "&pgm..sas"; *--user wanted a table of state-of-Missouri weights as per: 5-year cohorts starting with 20-24 thru 85+ (wanted thru 95-99 but this was the best we could do). by sex and by white-alone vs not-white-alone and by metro/nonmetro (within a CBSA). May-June, 2015. ---*; libname popests '/pub/data/popests' access=readonly; libname temp "/pub/data2/temp"; *--user will want CSV but we can do that using Dexter vs the SAS set generated here-; proc format; value $age ' '='Total' 01=' 0 to 4' 02=' 5 to 9' 03='10 to 14' 04='15 to 19' 05='20 to 24' 06='25 to 29' 07='30 to 34' 08='35 to 39' 09='40 to 44' 10='45 to 49' 11='50 to 54' 12='55 to 59' 13='60 to 64' 14='65 to 69' 15='70 to 74' 16='75 to 79' 17='80 to 84' 18='85+'; value $sex ' '='Total' 1='Male' 2='Female'; run; data cells; set popests.mocasrh13; where sumtype='asr' and age ge '05'; length Metro $10 White $10; retain Year "2013"; Pop=popest_2013; if cbsa=' ' then Metro="Non-Metro"; else Metro="Metro"; if race='01' then White="White"; else White="Non-White"; format age $age. sex $sex.; keep age white metro sex Pop; run; proc summary nway data=cells noprint; class metro Sex White Age; var pop; output out=ageracesexmetro sum=; run; data temp.ageracesexmetro(label="From setup in popests/Tools/&pgm"); retain Metro White age sex pop; set _last_ (rename=(age=_agecode sex=_sexcode)); length age $8 sex $6; age=put(_agecode,$age.); sex=put(_sexcode,$sex.); drop _: ; run; proc print data =_last_; by metro; id Sex white age; *where Age<='10'; run;