x cd /pub/data/sf12010x/Tools; %let pgm=cnvt_sf12010x_moregns; filename pgm "&pgm..sas"; *----Create a series of standard extract data sets for special datasets. See also setup in cnvt_sf12010x.sas . jgb, OSEDA, MCDC . 12/2011. ----*; %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=1; %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.regns (label="&statenm county-based regions"); length SumLev $3 esriid $4 areaname $64 ; **set sf1.&stab.regns; merge sf1.&stab.regns(in=in10) sf1x2k.moregns(keep=sumlev region totpop rename=(totpop=totpop2k) in=in2k); by sumlev region; if in10; if first.sumlev and not in2k then put "***No 2000 data found for " sumlev= region= ; %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 geocode sumlev region ded_region dot rpc umx umx2 aaa areaname region ; keep IntPtLon IntPtLat AreaSQMI LandSQMI ; keep TotPop -- AvgSizeRenter; esriid=geocode; %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.regns; geocode=compress(geocode,'-.'); run; filename dlmout "/pub/data/temp/sf1x&stab.regns.csv"; %cnvtdlm( lrecl=4096,names=1,quotes=0) ; run; %end; %endmac: %mend doit; %doit(29,mo,Missouri);