x cd /home/riceg/ACS_SAS_processing; %let pgm=process_basetabs1yr; filename pgm "&pgm..sas"; /* Process the base tables datasets stored in the temptabs subdirectory (we moved them there). We merge the geos data and modify the format for this platform. */ %let year=2017; %let period=1; *-- can be 1 or 5 ; %let yearm4=%eval(&year-4); %let yearm2=%eval(&year-2); %let yr=%substr(&year,3,2); %let cbsayr=15; %let geosetname=allgeos&period.yr; title "&pgm.: Convert &year &period Geographic headers Data"; options compress=yes; %include '/pub/sas/autoexec.sas'; *libname user '/SAS_temp/user'; *-- May not need this. Space could be a problem with 5yr sets. ; libname acs&year "/pub/data/acs&year"; libname temptabs "/pub/data/acs&year/base_tables_1yr/newtabs"; ** access=readonly; libname basetbls "/pub/data/acs&year/base_tables_1yr"; %let tabset=00_07; /* ========================begin comment==================================== *-- stopped doing this a while ago ; proc datasets library=temptabs nolist; *-- sort problem with these having to do with PR data with blank State. ; modify ustabs&tabset; index create sg=(state geoid); modify ustabs&tabset._moes; index create sg=(state geoid); quit; ==========================end comment====================================== */ %macro dotabset(tabset,sort=1,moes_only=0); %if &sort %then %do; proc sort data=temptabs.ustabs&tabset out=ustabs&tabset; by state geoid; run; proc sort data=temptabs.ustabs&tabset._moes out=ustabs&tabset._moes; by state geoid; run; %end; %if &moes_only %then %goto moes; data basetbls.ustabs&tabset(sortedby=state geoid label="US base tabs for topics &tabset - &period.yr data vintage &year" ); merge acs&year..&geosetname(in=ingeos) ustabs&tabset (in=indata rename=(logrecno=logrecnock)); by state geoid; if logrecno ne logrecnock then do; put /"*** Logic or data problem: logrecno values do not match. Run is aborting ***" / geoid= state= logrecno= logrecnock= _n_= ingeos= indata= ; abort abend; end; drop logrecnock; run; %moes: data basetbls.ustabs&tabset._moes( compress=no label="US base tabs MOE values only for topics &tabset - &period.yr data vintage &year" ); length State $2 geoid $40 SumLev $3 Geocomp $2 Logrecno 8; set ustabs&tabset._moes(rename=(logrecno=logrecnoC)); Sumlev=substr(geoid,1,3); geocomp=substr(geoid,4,2); Logrecno=logrecnoC; drop logrecnoC; *-- we convert it to numeric ; run; %mend dotabset; %dotabset(00_07,sort=1); %dotabset(08,sort=1); %dotabset(09_16,sort=1); %dotabset(17_20,sort=1); %dotabset(21_24,sort=1); %dotabset(25_28,sort=1); %include sascode(notify);