x cd /pub/data/popests/Tools; %let pgm=huestsYY; filename pgm "&pgm..sas"; *---Convert the U.S. housing unit ests for US thru 20YY. jgb, 10-25-06 jgb, 09-15-07 jgb, 08-30-08 jgb, 11-03-09 jgb, 06-29-10 and again 9-9-10 after revision to data. jgb, 06-14-12 new decade begins with vintage 2011 estimates jgb, 07-01-13 vintage 2012 estimates . New format, had to tweak the code. jgb, 05-01-14 vintage 2013 estimates . jgb, 05-21-15 vintage 2014 estimates . jgb, 05-19-16 vintage 2015 estimates . jgb, 05-25-17 vintage 2016 estimates . ---; %let baseyear=2010; *<---new parm, 6-12--; %let hucen=hucen10; *--was hucen2k in previous decade--; %let year=2016; %let yr=%substr(&year,3,2); *filename in "/pub/data/popests/rawdata/HU-EST&year._US.CSV" termstr=crlf;*<--downloaded from //www.census.gov/popest/data/housing/totals/2011/HU-EST2011-CO.html; *--the downloaded file was PEP-2014_PERANNHU.zip in the rawdata dir. We unzipped the CSV file inside and copied it to this huest&year..csv-; *filename in "/pub/data/popests/rawdata/huests&year..csv"; *-beginning 2013 we use AFF to download this to .zip file, etc.-; filename in "/pub/data/popests/rawdata/PEP_2016_PEPANNHU_with_ann.csv"; *-beginning 2016 we find this filename inside our PEP_2016_PEIPANNHU.zip-; libname popests '/pub/data/popests'; title "&pgm : Read Estimates of Housing Units by County &baseyear.-&year., Entire US"; options fmtsearch=(work sasctlgs popests); Missing a; data aggin; infile in dsd missover firstobs=3 termstr=crlf; length State $2 County Fipco $5; %macro loop; %global year; %local yy; %do yy=&baseyear %to &year; huest_&yy %end; %mend loop; *---format changed starting with 2012 data released in 2013----; length _geoid $14 _geoid2 $5 _CTYNAME $40 &hucen huestbase %loop 5; label &hucen="HU Count Per &baseyear Census" huestbase="HU Estimates Base, &baseyear"; input _geoid -- huest_&year; State=substr(_geoid,10,2); fipco=Substr(_geoid,10,5); county=fipco; drop _: ; run; proc print data=aggin(obs=25); title2 'aggin'; by fipco county; id fipco county; run ; proc summary data=aggin; class state county; var &hucen HUest: ; output out=sums(drop=_freq_) sum=; run; data popests.ushuest&year(label="U.S. housing unit estimates by county, &baseyear.-&year"); length SumLev $3 State $2 County geocode $5 AreaName $64; set sums; where _type_ ne 1; select (_type_); when (0) do; SumLev='010'; State='00'; AreaName='United States'; end; when (2) do; SumLev='040'; Areaname=put(state,$state.); geocode=state; end; when (3) do; SumLev='050'; AreaName=put(county,$county.); geocode=county; end; end; ChangeHUs=huest_&year - huestbase; PctChangeHUs=100*ChangeHUs/huestbase; label ChangeHUs="Change in HU count since &baseyear." PctChangeHUs="% Change in HU count since &baseyear."; format pctchangeHUs 6.1; drop _type_; run; proc sort; by state county; run; proc print data=&syslast (obs=100); title2 "&syslast"; by state; id sumlev county; run; proc sql; create table popests.mohuest&year as select * from popests.ushuest&year where state='29'; quit; proc print data=&syslast (obs=125); title2 "&syslast";