x cd /pub/data/acs/Tools; %let pgm=create_usmcdcprofiles_since2006; filename pgm "&pgm..sas"; *----Create acs.usmcdcprofiles2006_&year -- a time series data set containing the usmcdcprofiles (1yr) data from each year starting with 2006 thru the latest (see &year parm value). jgb Oct. 2012. (original coding). Running 5-11-15 to get data thru 2013. Running 3-9-17 to get data thru 2015. ---; options mprint; *libname acs clear; libname acs '/pub/data/acs'; %let year=2015; %let setout=usmcdcprofiles2006_&year; options compress=no; *--Compressing only decreased the size by 8 pct--; *--These datasets were sorted by geoid early on but in recent years by state geoide. So we create some indices to allow our merge to work by geoid. --; /*<=========================Comment out===================================== *---------------we processed this interactively------------------------------*; %macro geoidindex(year); libname tempacs "/pub/data/acs&year"; proc datasets nolist library=tempacs; modify usmcdcprofiles; index create geoid; quit; libname tempacs clear; %mend geoidindex; %geoidindex(2013); %geoidindex(2014); %geoidindex(2015); ===========================End commented out================================ */ %macro doyrs(what); %*---dual-purpose macro generates the code for all the years. What code depends on the value of parm what---; %do iyear=2006 %to &year; %if &what=libname %then %do; libname acs&iyear "/pub/data/acs&iyear" %if &iyear ne &year %then %str(access=readonly); ; %end; %else %if &what=refset %then %do; acs&iyear..usmcdcprofiles(in=in&iyear drop=dateCreated) %end; %end; %mend doyrs; %doyrs(libname) ; *---Create an index for the latest year so that it can be accessed BY GEOID ---; *proc datasets library=acs&year nolist; *modify usmcdcprofiles; *index create geoid; * run; /*<=========================Comment out===================================== data acs.usmcdcprofiles2006_&year(label="Interleaving of all usmcdcprofiles sets for years 2006 to &year"); retain Year " "; if 0 then set acs&year..usmcdcprofiles ; *---To establish variable order and other characteristics in PDV--; retain latestYear "&year"; set %doyrs(refset); by geoid; if TotPop; *--we had some garbage records with no data esp for PR---; Year=Years; drop years; *--we go with the singular to emphasize that these are single-year data--; *--The variable we now call metdiv used to be called metrodiv. This code makes it consistent--; if metrodiv ne ' ' then metdiv=metrodiv; drop metrodiv; if cbsa ne ' ' and cbsayr=' ' then do; if "2006"<=years<="2008" then cbsayr=years; else if "2009"<=years<="2012" then cbsayr="2009"; else if years<="2014" then cbsayr='2013'; else cbsayr='2015'; *<---not positive about this--; end; if esriid = " " and sumlev ne "010" then esriid=substr(geoid,8); geocomp_name=geocomp; *--In earlier years we stored the actual name. Now we use a format code.--; format geocomp_name $geocomp.; drop NonInstUnde pctNonIn ; *--not sure which set had these but they were a mistake---; run ; proc sort data=acs.&setout; by year state sumlev geocomp esriid; run; proc datasets nolist library=acs; modify &setout; index create geoid; index create year; index create state; index create sumlev; quit; ===========================End commented out================================ */ *----Create an alternate version (a view) that has no margin-of-error variables---*; proc contents data=acs.&setout noprint out=varnames(keep=name); run; proc sql noprint; select lowcase(name) into :moevars separated by ' ' from varnames where index(lowcase(name),'_moe'); %put &moevars; data acs.&setout._nomoes /view=acs.&setout._nomoes; set acs.&setout (drop=&moevars); run; data acs.mostcnty2006_&year(label="Missouri state and county summaries 2006-&year w no moes" index=(year)); set acs.&setout._nomoes; where state='29' and sumlev in ('040','050'); where also geocomp='00'; run; ods html file="&setout._Frequencies.html" style=meadow; proc freq data=acs.&setout (keep=year sumlev state geocomp where=(geocomp='00')); title "Frequencies on acs.&setout with geo components Ignored"; tables (sumlev state geocomp)*year; format sumlev $sumlev. geocomp $geocomp. ; format state $statewc.; run; proc freq data=acs.&setout (keep=year sumlev state geocomp where=(geocomp ne '00')); tables sumlev*geocomp ; by year; title "...and now: Frequencies for Geographic Components Only"; run; ods html close;