x cd /pub/data/sf12010x/Tools; %let pgm=cnvt_sf12010x_mocdslds2012; filename pgm "&pgm..sas"; *----Create a standard extract data set for the revised voting district, Mo only . jgb, OSEDA, MCDC . 5/2012. Tweaking to add stab variable 6-4-12. ----*; %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,statenm); %let ustab=%upcase(&stab); %if &csvfiles = 1 %then %goto csvblks; data sf1x.&stab.cdslds2012 (label="Missouri CD and SLDS vintage 2012"); length SumLev $3 esriid $8 areaname $64 ; Retain stab "&stab"; **set sf1.&stab.regns; set sf1.&stab.cdslds2012(in=in10); ***NO 2000 pop. sf1x2k.moregns(keep=sumlev region totpop rename=(totpop=totpop2k) in=in2k); * by sumlev region; * if in10; %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.cdslds2012; geocode=compress(geocode,'-.'); where county=' '; *<---no within-county summaries for the CSV files / sf1profiles.--; run; filename dlmout "/pub/data/temp/sf1x&stab.cdslds2012.csv"; %cnvtdlm( lrecl=4096,names=1,quotes=0) ; run; %end; %endmac: %mend doit; %doit(29,mo,Missouri);