x cd /pub/data/sf32000x/Tools; %let pgm=cnvtsf3xus; filename pgm "&pgm..sas"; /*---Access Census 2000 full sf3 US level datasets and create standard extract datasets and/or metadata (Variables) dataset. Input filetype is sf32000, output filetype is sf32000x. Real work is mostly done in the included file invoke_dovars.sas . Last rerun: 11-11-02 (after fix to NonFamilyHHs.) 2-13-03: running usgeocomp convert only to keep geocomp code. 01-04-05: running to fix problems with Under18 and Over21 - should have been rerun last May! (v9) 09-27-06: running most of the converts (except usmcds) to get rid of extraneous geocodes and add zcta3 where it is relevant. 11-01-06: Previous run (9-27) inadvertently did not rerun all the converts we wanted. So try again. 12-13-06: Running conversion for uspumas. 11/20/2009 after update to the disabled65 var. 12/11/2013 - we discover that all these conversions run back in Nov 2009 were using setout=(sf3x.)usregdiv ! So the contents of sf3x.usregdiv is actually sf3x.usother and none of these data sets had the value of disable65 fixed for the last 4+ years. Aaaargh. (We added setout parm on the macro to fix the bug which only assigns a new value to &setout if it is null.) 12/12/2013 - Reran the usother convert to insert "106th " at the start of Areaname for the CD summaries. This is the name that appears on the dp3_2k reports and we need it because we have 3 states where we have data for the 108th districts. ---*/ %global temp; *--set this parm to a value of %str(/temp) when reading and writing from the temp subdir (embargoed)-; %*let temp=%str(/temp); %let temp=; %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. --*; libname sf3 "/pub/data/sf32000&temp" access=readonly; libname sf3x "/pub/data/sf32000x&temp"; title "&pgm: Create sf32000x Extract Datasets from sf32000 Datasets"; %global pctof table curtable curtabno dvmode; %let curtabno=0; %macro cnvtmeta(mode,setout=,nogeocomps=0); %***global setin setout dvmode; %global setin dvmode; %if &setout=%str() %then %let setout=&setin; *--by default we use the input set name base as name of output set--; %let dvmode=&mode; %if &dvmode = %str(data) %then %do; *---------Here is the conversion data step-------------*; data sf3x.&setout; length default=5 Obs 5 esriid $16; %if %bquote(&setin)=usgeocomps %then %str(length geocomp_name $110;); %if %sysfunc(exist(sf3.&setin)) %then %do; set sf3.&setin; %end; %else %do; merge sf3.&setin.ph sf3.&setin.phct; by logrecno; %end; esriid=compress(geocode,'-.'); label esriid='Id field to link to ESRI map files'; %end; %else %put ***** dvmode parm value not recognized: value= &dvmode ; *<---This setup not supporting meta mode; options NOmprint; %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 (cnvtsf3x.sas) does not really define what sf32000x is, it is this included module that really does it. ----; * label grcid='Id field to link to GRC/MsDIS map files (Mo only)'; %if %index(&setin,geocomps) %then %do; geocomp_name=put(geocomp,$geocomp.); keep geocomp geocomp_name; %end; %if &nogeocomps %then %do; where geocomp='00'; %end; Obs+1; label Obs='Observation #'; keep Obs esriid geocode sumlev areaname logrecno esriid state stab county msacmsa pmsa ua placefp cousubfp ; keep IntPtLon IntPtLat AreaSQMI LandSQMI lsadc; keep TotPop -- AvgHValue; %mend cnvtmeta; %let temp=; options NOmprint; /*<=========================Comment out===================================== %let setin=usregdiv; %cnvtmeta(data,nogeocomps=1) ; drop state stab county cousubfp placefp msacmsa pmsa ua ; keep region division; run; %let setin=usgeocomps; %cnvtmeta(data) ; run; %let setin=usstcnty; %cnvtmeta(data) ; drop cousubfp placefp ua; run; %let setin=usplaces; %cnvtmeta(data) ; drop county cousubfp ua; run; %***let setin=usmcds; %****cnvtmeta(data) ; *<======================cannot rerun because parent dataset is damaged and cannot be accessed=; *** run; %let setin=uszips; %cnvtmeta(data) ; keep zcta3 zcta5; drop county cousubfp placefp msacmsa pmsa ua lsadc; run; %let setin=usuas; %cnvtmeta(data) ; drop county cousubfp placefp msacmsa pmsa; run; ===========================End commented out================================ */ %let setin=usother; %cnvtmeta(data) ; if sumlev='500' then areaname='106th '||areaname; keep zcta3; run; /*<=========================Comment out===================================== libname sf32000x "/pub/data/sf32000x"; proc sql; create view sf32000x.usmsas00 as select * from usother where SumLev in ('380','381','385','386'); create view sf32000x.usuas00 as select * from usother where SumLev in ('400','410'); create view sf32000x.uszip3s as select * from sf32000x.usother where SumLev='850'; quit; *---running this one for all pumas in US 12-06----*; %let setin=uspumasph; %*let setout=uspumas; %cnvtmeta(data); keep puma5 counties places; drop county cousubfp placefp msacmsa pmsa ua lsadc ; drop PCT19i: PctFB: FB: PCT8i3; esriid=compress(geocode,'-'); run; ===========================End commented out================================ */