x cd /home/riceg/ACS_SAS_processing; %let pgm=genTableSelects; filename pgm "&pgm..sas"; %include '/pub/sas/autoexec.sas'; *----Generate server-side include select modules describing the tables in 1990 stf files and 2000 summary files (sf12000 and sf32000). Also ctpp and the acs20XX datasets. We do extensive editing of the table names to make them short enough for use within the Dexter app. Creates the modules (in /includes/selects): sf32000_tables.html, sf32000ph_tables.html, sf32000phct_tables.html, etc. jgb and ig, Jan 2005. Revised: 3/8/07 - generating html files for new combined acs2005 table sets. 11/08: generate html files for acs2006 and acs2007 table sets. 03/10: regen acs2006 & acs2007 with new sort order. 9-30-09: Generating selects for the acs2008 basetbls. 10-07-10: Generating selects for the acs2009 basetbls. (But bce got there first so they were created elsewhere). 06-20-11: Generating selects for the sf12010 table data sets. 09-24-11: Generating select for acs2010 basetbls. 09-27-12: Generating select for acs2011 basetbls. 09-23-15: Generating select for acs2014 basetbls. 09-14-16: Generating select for acs2015 basetbls. 02-18-17: Generating select for acs2015 5yr basetbls. (!) 03-08-17: Regenerating the acs2015 5bg modules. 06-28-17: Regenerating the acs2015 5yr and 5bg modules. 12-14-18: Regenerating the acs2016 5yr and 5bg selects. 12-14-18: Generating the acs2017 1yr, 5yr and 5bg selects. 09-26-19: Generating the acs2018 1yr selects. ----*; libname user '/SAS_temp/user'; %macro edtname; if length(tablename) ge 99 then tablename = tranwrd(tablename, "Percentage", "Pct"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Percent Of", "Pct"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Hispanic Or Latino","Hispanic"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "hispanic Or Latino","Hispanic"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "some Other Race","Other"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Not Hispanic","NH"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "not Hispanic","NH"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Black Or African American","Black"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "black Or African American","Black"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Pacific Islander", "PI"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Householder", "HHldr"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Household", "HH"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Aggregate HH Income", "Agg HH Inc"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "(dollars)", "($)"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Under 18", "< 18"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Over 18", "> 18"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Housing Units", "HUs"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Specified", "Spec"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Owner-Occupied", "Own-Occ"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Mortgage Status", "Mtg Stat"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Population", "Pop"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Group", "Grp"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Quarters", "Qtrs"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "american Indian", "Am. Ind."); if length(tablename) ge 99 then tablename = tranwrd(tablename, "alaska Native", "Alaskan"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Alaska Native", "Alaskan"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "native Hawaiian", "Nat Haw."); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Combination", "Comb."); if length(tablename) ge 99 then tablename = tranwrd(tablename, "With one or more", "W 1+"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Categories", "Cats"); if length(tablename) ge 99 then tablename = tranwrd(tablename, " And ", " & "); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Related Children", "Rel. Kids"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Language Spoken at Home", "Lang Sp @Hm"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Ability To Speak English", "Spk Eng."); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Usual Hours Worked Per Week","Usual Hrs/Week"); if length(tablename) ge 99 then tablename = tranwrd(tablename, " Years & Over","+"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Weeks Worked","Wks Wrkd"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Industry","Ind."); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Employed Civilian Pop","Emp Civ Pop"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Families By Family Type","Families by Type"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Noninstitutionalized","Noninst"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "School By Type of School","School by Type"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "School","Schl"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "By Level Of Schl By Type Of Schl","by Lvl by Type"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Educational Attainment","Ed. Attain."); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Enrollment","Enrlmnt"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "16 To 19","16-19"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Two Or More","2+"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "two Or More","2+"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Employment Status","Emp. Stat"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "As A Pct","as Pct"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Facilities","Facs"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Selected Monthly Owner","Sel Mthly Ownr"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Income In 1999","Income"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Income In 1989","Income"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "(including Living Alone)",""); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Presence Of Own Children","Own Kids"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Unrelated Individuals","Unr. Inds"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Year","Yr"); if length(tablename) ge 99 then tablename = tranwrd(tablename, " Of ",""); if length(tablename) ge 99 then tablename = tranwrd(tablename, " For The ",": "); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Civilian","Civ"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Employment","Emplymt"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Aggregate","Agg"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Work Experience","Wrk Exp."); if length(tablename) ge 99 then tablename = tranwrd(tablename, " < ","<"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Status","Stat"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Family Type","Fam Type"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Families & Subfamilies","Fams & SubFams"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Living Arrangements","Lvng Arngmnts"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "With ", "w "); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Children","Kids"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Or More ","+ "); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Hrs/Week In 1999 By Wks Wrkd In 1999","Hrs/Week x Wks Wrkd in 99"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Earnings ","Erngs "); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Selected","Slctd"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Characteristics","Chrstcs"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Poverty Level","Pov Lvl"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Poverty Status","Pov Stat"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Income","Inc"); if length(tablename) ge 99 then tablename = tranwrd(tablename, " By "," x "); if length(tablename) ge 99 then tablename = tranwrd(tablename, "1989","89"); tablename = tranwrd(tablename, "Grandhildren","Grandkids"); *-- note we are correcting a bad entry in cdbk here ; if length(tablename) ge 99 then tablename = tranwrd(tablename, "Grandchildren","Grandkids"); if length(tablename) ge 99 then tablename = tranwrd(tablename, "Grandchildren","Grandkids"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"Grandparents", "Grndprnts"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"Grandparent", "Grndprnt"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"Responsibility For Own Grandkids","Resp. for Grandkids"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"2005 Inflation-Adjusted Dollars", "2005 Dollars"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"2006 Inflation-Adjusted Dollars", "2006 Dollars"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"2007 Inflation-Adjusted Dollars", "2007 Dollars"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"In The Past 12 Months", "Past 12 Mos"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"(In 20","(20"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"Minor Civil Division", "MCD"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"(Ct, Me, Ma, Mi, Mn, Nh, Nj, Ny, Pa, Ri, Vt, Wi)"," "); if length(tablename) ge 99 then tablename = tranwrd(tablename,"American Indian","Am Indn"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"Some Other Race","Othr Rc"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"Native Hawaiian","Natv Hawn"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"United States","US"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"Current Residence","Curr Res"); if length(tablename) ge 99 then tablename = tranwrd(tablename,"Statistical Area","Stat Area"); if length(tablename) ge 99 then tablename = tranwrd(tablename," x ","X"); if length(tablename) ge 99 then do; %chopwrd(tablename); end; %mend edtname; *-- Adapting this code 9-30-09 so that it works for multiple years with new global &acsyear ; %global acsyear; %global tableno; *-- flag indicating whether tableno appears as variable in variables metasets ; %macro acstabs(tabset,list=0); %global acsperiod B; *-- adding acsperiod 2017. Will experiment using this to generate 5yr select tabs for vintage 2016 datasets ; *-- The B parm being used 2-18-17 to indicate a suffix on the Variables data sets. The updated version of metadata will have this B parm (stands for Blodgett) ; *-- we now have 3 different menu sets per vintage. The old 1 year tabs, the 5yr tabs and the 5bg block group tabs ; %if %superq(acsperiod)=%str() %then %let acsperiod=1; %else %if %superq(acsperiod)=5bg %then %let sfx=5bg; %else %if %superq(acsperiod)=5 %then %let sfx=5yr; %else %let sfx=%str(); filename tabs "/pub/includes/selects/new/acs&acsyear&tabset.&sfx._tables.html"; *<== key stmt says where we write to ; *-- Sometimes we do not have tableno as a separate variable. So we create it on the fly when needed ; %if &tableno %then %let _tableno=tableno; %else %let _tableno=%str( substr(tableID,2,5) as tableno ); /* June 2017: we now realize that we have to distinguish between availability for alpha-suffix tables distinct from no-suffix tables. The new flag variables Avail5yrAlpha and AvailBGsAlpha pertain to the table, as do Avail5yr and AvailBGs. So a little extra preprocessing step added here. */ data variables&tabset&B ; set basetbls.variables&tabset&B; where TableCell=1; *-- gets repeated as filter in next step. Which is OK ; if tableRSfx ne ' ' then do; Avail5yr=Avail5yrAlpha; AvailBGs=AvailBGsAlpha; end; run; proc sql; create table metatabs as select TableSeqNo, TableId, TableName, tabset, universe, ncellsintable, &_tableno , tablersfx, tabletype from variables&tabset&B where TableCell=1 %if &acsperiod=5 %then %do; and Avail5yr='Y' %end; %if &acsperiod=5bg %then %do; and Avail5yr='Y' and AvailBGs='Y' %end; order by TableNo, TableRSFX, tabletype ; quit; data tables&tabset; set metatabs; *where tabset="&tabset"; %edtname; *_newseqno+1; if length(tablename) ge 99 then do; _lname=length(tablename); put "**name too long: " _lname= tablename=; tablename=substr(tablename,1,98); *-- append the table size to the label ; end; tablename=trim(tableid)||':'||trim(tablename)||' ('||trim(left(put(ncellsintable,4.)))||')'; drop _: ; keep tableid tablename universe ncellsintable; keep tableNo TableRSFx tabletype; run; %genslct(setin=tables&tabset,fileout=tabs,name=table,size=15,multiple=1,valvar=tableid, labelvar=tablename,sortby=%str(TableNo, TableRSFx, tabletype)) ; run; %if &list %then %do; data _null_; infile tabs obs=&list; input; file print; put _infile_; title2 "Select list for &tabset"; run; %end; filename tabs clear; %mend acstabs; %macro doacsyr(doyear); %global acsyear; %global acsperiod b; %let acsyear=&doyear; *-- used in acstabs macro below ; libname basetbls "/pub/data/acs&acsyear./base_tables_1yr" access=readonly; options NOmprint; %acstabs(00_07,list=999) ; %acstabs(08,list=999) ; %acstabs(09_16,list=999) ; %acstabs(17_20,list=999) ; %acstabs(21_24,list=999) ; %acstabs(25_28,list=999) ; %mend doacsyr; %let tableno=0; %let acsperiod=1; %let B=; %doacsyr(2018) ;