x cd /pub/data/acs2012/Tools; %let pgm=create_usmcdcprofiles_since2006; filename pgm "&pgm..sas"; *----Create a time series data set containing the usmcdcprofiles data from each year starting with 2006 thru the latest. (For the 3-year datasets we start with 2005-2007 so it is actually starting with vintage year 2007.) Original idea was implemented in the create_usmcdsprofile_since2006.sas setup in /pub/data/acs/Tools. [Sic- note extra "s"]. Starting with 2012 vintage we shall now create both 1 and 3yr sets for all years from 2006 to latest. NO plans to do this for 5yr data sets. jgb, jan, 2014. ---; options mprint; %let year=2012; libname acs '/pub/data/acs2012'; /*<=========================Comment out===================================== *---We will try defining indices that can allow us to process sets that are not already sorted by geoid---; proc datasets library=acs nolist; modify usmcdcprofiles; index create geoid; modify usmcdcprofiles3yr; index create geoid; quit; ===========================End commented out================================ */ %let yearm2=%eval(&year - 2); title "&pgm.: Create Time Series Data Sets for 2006-&year"; %macro doyrs(what,p2); %*---dual-purpose macro generates the code for all the years. What code depends on the value of parm what---; %if &what=refset and &p2=3 %then %let lowyear=2007; %else %let lowyear=2006; %do iyear=&lowyear %to &year; %if &what=libname %then %do; libname acs&iyear "/pub/data/acs&iyear" access=readonly; %end; %else %if &what=refset %then %do; acs&iyear.. %if &p2=3 %then %str(usmcdcprofiles3yr ); %else %str(usmcdcprofiles ); (in=in&iyear drop=dateCreated) %end; %else %if &what=assignyears %then %do; if in&iyear then do; vintage="&iyear"; %if &p2=1 %then %str( Years=vintage;); %else %do; %let iyearm2=%eval(&iyear - 2); Years="&iyearm2.-&iyear"; %end; end; %*--if in&iyear .... ---; %end; %*---assignyears do group-------; %end; %*--do iyear loop--; %mend doyrs; %doyrs(libname) ; %macro doperiod(p); title2 "Concatenating All the Yearly Sets to Create acs.usmcdcprofiles_2006_&year&p.yr "; %if &p=3 %then %let lenyears=9; %else %let lenyears=4; data acs.usmcdcprofiles_2006_&year&p.yr(label="Interleaving of all usmcdcprofiles &p.yr sets for years 2006 to &year"); retain Vintage "&year" period "&p"; length Years $&lenyears ; set %doyrs(refset,&p); by geoid; %doyrs(assignyears,&p); run ; proc freq data=acs.usmcdcprofiles_2006_&year&p.yr (keep=years sumlev state); tables (sumlev state)*years; format sumlev $sumlev.; run; %mend doperiod; %doperiod(1) ; %doperiod(3) ;