x cd /pub/data/acs/Tools; %let pgm=gen_acsvarlist; filename pgm "&pgm..sas"; /* access the variables metadata set for latest cycle to generate macro variables acsmeans, acsmwts, pctvars, pctwts which can be used to aggregate the 5yr data sets. We do separate set of parms for the bg data sets. We ran this from the acsVVVV/Tools directories in years 2011 and earlier. Moved to generic acs starting with the 2012 vintage cycle. */ %let year=2022; %let yr=%substr(&year,3,2); %include '/pub/sas/autoexec.sas'; %libname (acs&year); libname acs (acs&year); libname user '/SAS_temp'; *options nosymbolgen nomprint nosource ; options symbolgen mprint mlogic source ; %*-- Define a macro that will return a series of quoted words from a string of text not containing any quotes. E.g. arg is January February March, output is "January" "February" "March". Blanks are delimiters on input.If dlmtr is specified the output string has words separated by that string rather than the default blanks. --; %macro qwords(in,dlmtr=%str( )); %local n word; %let n=1; %let word=%scan(&in,1,%str( )); %do %while (&word ne %str()); "&word" &dlmtr %let n=%eval(&n+1); %let word=%scan(&in,&n,%str( )); %end; %mend qwords; data variables5; set acs.variables5yr(keep=variable_name percent_variable wtvar univvar); retain acs5yrvars "%varlist(_numeric_,acs.ustracts5yr)"; if _n_=1 then acs5yrvars=upcase(acs5yrvars); if index(acs5yrvars,trim(upcase(variable_name))) then output; else put variable_name= ' --deleted ***'; run; proc sql noprint; select percent_variable into :pctvars separated by " " from variables5 where percent_variable ne ' '; select univvar into :pctwts separated by " " from variables5 where percent_variable ne ' ';; select variable_name into :means separated by " " from variables5 where wtvar ne ' '; select wtvar into :mwgts separated by " " from variables5 where wtvar ne ' '; quit; data _null_; set acs.ustracts5yr(keep= &pctvars &means); *---this will trigger errors when we have variables not on data set-; stop;run; %put _global_; *<====See code below for BGs. We should be able to automate the generation of the parms file.--; *---------------Generate the aggvarsparms&year..sas file that will be used in caps10acsb when processing tract level data----; filename trparms "/pub/data/acs/Tools/aggvarparms&year..sas"; data _null_; file trparms linesize=132 flowover; put "*--Generated from setup in acs/Tools/&pgm..sas at &systime on &sysdate .--*; "; put '%let ACSMEANS=' %qwords(&means,dlmtr=%str( +1 )) ';' /; put '%let ACSMWGTS=' %qwords(&mwgts,dlmtr=%str( +1 )) ';' /; *---these are not on any of the datasets except BG and then only when we do enhanced addition from Linux side---*; put '%let PCTVARS=' %qwords(&pctvars, dlmtr=%str( +1 )) ';' /; put '%let PCTWTS= ' %qwords(&pctwts, dlmtr=%str( +1 )) ';' /; run; data _null_; infile trparms; input; put _infile_; run; data variables5bg; set acs.variables5yr(keep=variable_name percent_variable wtvar univvar); retain acs5yrvars "%varlist(_numeric_,acs.usbgs5yr)"; * This messes up percentages in tables E5, S2, S3! ; *NoPercentVar= (univvar in ('CivLabForce','HHPop','Over16') or Variable_name='PovUniverseFamilyPop'); NoPercentVar = 0; if _n_=1 then acs5yrvars=upcase(acs5yrvars); if index(acs5yrvars,trim(upcase(variable_name))) then output; else put variable_name= ' --deleted ***'; drop acs5yrvars; run; proc sql noprint; select percent_variable into :pctvarsbg separated by " " from variables5bg where (percent_variable ne ' ' and NoPercentVar=0) ; select univvar into :pctwtsbg separated by " " from variables5bg where (percent_variable ne ' ' and NoPercentVar=0) ; select variable_name into :meansbg separated by " " from variables5bg where wtvar ne ' ' ; select wtvar into :mwgtsbg separated by " " from variables5bg where wtvar ne ' ' ; select variable_name into :allVars separated by " " from variables5bg ; data _null_; *---this will trigger errors when we have variables not on data set-; set acs.usbgs5yr(keep= &pctvarsbg &meansbg &pctwtsbg &mwgtsbg); stop;run; *---------------Generate the aggvarsparms&year.bg.sas file that will be used in caps10acsb for bgs----; filename bgparms "/pub/data/acs/Tools/aggvarparms&year.bg.sas"; data _null_; file bgparms linesize=132 flowover; put "*--Generated from setup in acs/Tools/&pgm..sas at &systime on &sysdate .--*; "; put '%let ACSMEANSBG=' %qwords(&meansbg,dlmtr=%str( +1 )) ';' /; put '%let ACSMWGTSBG=' %qwords(&mwgtsbg,dlmtr=%str( +1 )) ';' /; put '%let PCTVARSBG=' %qwords(&pctvarsbg, dlmtr=%str( +1 )) ';' /; put '%let PCTWTSBG=' %qwords(&pctwtsbg, dlmtr=%str( +1 )) ';' /; run; data _null_; infile bgparms; input; put _infile_; run; %put &allVars; %include sascode(notify);