x cd /pub/data/sf12010x/Tools; %let pgm=cnvt_sf12010x_uscdslds2012; filename pgm "&pgm..sas"; *----Create a standard extract data set for the 2012 vintage new geos (cd113, revised SLDs and PUMAs for all 51 states. jgb, OSEDA, MCDC . 10/2014. Modeled after cnvt_sf12010x_mocdslds2012 (which was run back in 4/12 with early Mo only data.) ----*; %global csvfiles; %let csvfiles=2; %*---Has 3 values: 0 means no CSV files be generated. 1 means only CSV files, no conversion. and 2 meaning do conversions AND CSV files . ----; libname sf12010 "/pub/data/sf12010" access=readonly; libname sf1 (sf12010); *--alternate libref--; libname sf12010x '/pub/data/sf12010x'; libname sf1x (sf12010x); *--alternate libref--; *** libname sf1x2k '/pub/data/sf12000x' access=readonly; %let moe_default=; %let dvmode=data; %*--the "dovar mode" global parm controls what kind of output is generated by the dovar macro. The values are data or meta, which cause it to either generate actual conversion data step code or code to create metadata set Variables. The value is also looked at by smaller macros which generate the start and end of the data steps during which the dovar macro invocations take place. --*; title "&pgm: Create sf12010x Extract Datasets from sf12010 Datasets"; %global pctflag; *---used by invoke_dovars to conditionally generate code depending on whether PCT tables are available for the level; %let pctflag=0; %global pctof table curtable curtabno dvmode; %let dvmode=data; %let curtabno=0; %macro doit(state,stab); %let ustab=%upcase(&stab); %if &csvfiles = 1 %then %goto csvblks; data sf1x.&stab.cdsldspumas2012 (label="&statenm 113th CD + 2012 vintage SLDS & PUMAs"); **length SumLev $3 esriid $8 areaname $64 ; set sf1.&stab.cdsldspumas2012(in=in10 rename=(pop2k=totpop2k)); %include 'invoke_dovars.sas'/NOsource2; %*<----this module does the work of assigning the global parms and invoking the dovars parm for each variable on the dataset. Which means this module does not really define what sf12010x is, it is this included module that really does it. ----; keep _character_ ; keep IntPtLon IntPtLat AreaSQMI LandSQMI ; keep TotPop -- AvgSizeRenter; %if &pctflag=0 %then %do; drop hawaiian--PctOtherAsian mexican--PctOtherHispanic unmarriedPartner--PctUnmarriedPartner unmPartnerHHs--PctSameSexPrtnrHHs ; *---pct-based variables---; %end; drop _: ; run; %csvblks: %if &csvfiles ne 0 %then %do; data csvout; set sf1x.&stab.cdsldspumas2012; geocode=compress(geocode,'-.'); where county=' '; *<---no within-county summaries for the CSV files / sf1profiles.--; run; filename dlmout "/pub/data/sf12010x/cdsldspumas2012/&stab..csv"; %cnvtdlm( lrecl=4096,names=1,quotes=0) ; run; %end; %endmac: %mend doit; /*<=========================Comment out===================================== %dostates(n=51,names=1) ; ===========================End commented out================================ */ %macro setref(state,stab); sf1x.&stab.cdsldspumas2012 %mend; data sf1x.uscdsldspumas2012(label="Complete US concatenation of XXcdsldspumas2012 Datasets" index=(state)); set %dostates(n=51,mac=setref) open=defer; run; proc freq data=sf1x.uscdsldspumas2012; table state*sumlev; format state $state.; run;