x cd /pub/data/sf32000x/Tools; %let pgm=cnvtsf3x; filename pgm "&pgm..sas"; /*---Access Census 2000 full sf3 datasets and create standard extract datasets and/or metadata (Variables) dataset. Input filetype is sf32000, output filetype is sf32000x. This setup DEFINES what the sf32000x standard extract is. John Blodgett, OSEDA, U. of Missouri Outreach & Extension. Under contract with the Missouri Census Data Center. Revised (initial) version 8.22.02. Rerun 9-12-02 after fix to invoke_dovars to fix hhinc35 and hhinc50. Rerun 9-28-02 after fixes to hhinc50 (again) and hval300. 10-25-02 after fix to label on PctVacHUSample. Rerun 11-11-02 to keep more geo. variables: lat, long coords, areasqmi, landsqmi. Also after fix to defn of NonFamilyHHs. Rerun 5-20-04 after fix to under18 variable. Rerun 11-20-09 after fix to disabled65 variable (NOTE: The fixes referred to here are made in the invoke_dovars.sas module, which is included by this setup.) ---*/ %let dvmode=meta; %*--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" access=readonly; libname sf3x "/pub/data/sf32000x"; title "&pgm: Create sf32000x Extract Datasets from sf32000 Datasets"; %global pctof table curtable curtabno dvmode; %let curtabno=0; %macro cnvtmeta(mode); %global setin dvmode; %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.i sf3x.&setout.h sf3x.&setout.stcnty; length default=5 Obs 5 esriid $16; merge sf3.&setin.ph sf3.&setin.phct(in=inct); by logrecno; where geocomp='00'; ************Too confusing to keep *************; esriid=compress(geocode,'-.'); label esriid='Id field to link to ESRI map files'; %end; %else %if &dvmode=%str(meta) %then %do; *------Here is the data step that generate sf3x.Variables when dvmode=meta-----------; data sf3x.Variables(label="Meta data describing the variables on these datasets"); attrib Name label='Variable Name' length=$32 Label length=$80 format=$char. Definition length=$200 label='Definition - Code used to derive' Comment length=$400 Format length=$16 TypeLen length=$8 label='Variable type and length' Universe length=$64 UnivVar length=$32 label='Universe Variable' WtVar length=$32 label='Weight Variable' Lvl length=3 label="Data Indent Level" Display length=3 label="Display in std report?" PctFlag length=3 label='Pct Variable Flag' Table length=$64 TableNo length=3 label='Table #' Keywords length=$80 Year length=$4 Source length=$40 RefTables length=$40 label='Related Table(s)' ; *** OtherYears label='Other Years Available' length=$32; retain Year '2000'; retain Source 'Summary File 3, 2000 Census'; %end; %else %put ***** dvmode parm value not recognized: value= &dvmode ; options NOmprint; %include 'invoke_dovars.sas'; %*<----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. ----; %if &dvmode=%str(data) %then %do; label grcid='Id field to link to GRC/MsDIS map files (Mo only)'; if state='29' and geocode=:'29' then grcid=substr(esriid,3); if sumlev in ('040','050','060','140','150','155','160','170','280','230','374', '390','395','420','431','500','851','852','871','881') then do; _iobs+1; Obs=_iobs; output sf3x.&setout.i; if sumlev in ('040','050') then output sf3x.&setout.stcnty; end; else if not (sumlev=:'5') then do; _hobs+1; obs=_hobs; output sf3x.&setout.h; end; keep Obs esriid grcid geocode sumlev areaname logrecno esriid state stab county msacmsa pmsa ua placefp cousubfp tract bg zcta5; keep IntPtLon IntPtLat AreaSQMI LandSQMI lsadc; keep TotPop -- AvgHValue; label Obs='Observation #'; drop _iobs _hobs; run; *----Create 3 views for places, tracts and zipcodes----; proc sql; create view sf3x.&setout.tracts as select * from &setout.i(drop=cousubfp ua zcta5 placefp bg) where sumlev='140'; create view sf3x.&setout.bgs as select * from &setout.i(drop=cousubfp ua zcta5 placefp ) where sumlev='150'; create view sf3x.&setout.places as select * from &setout.i(drop=county msacmsa pmsa cousubfp ua zcta5 tract bg) where sumlev='160'; create view sf3x.&setout.zips as select * from &setout.i(drop=county msacmsa pmsa cousubfp ua tract placefp bg) where sumlev='871'; create view sf3x.&setout.msas00 as select * from &setout.i(drop=cousubfp ua zcta5 placefp county tract bg) where sumlev='390' or sumlev='395'; quit; %end; %else %if &dvmode=%str(meta) %then %do; *-----meta processing-----------------------------; run; options nonumber nodate orientation=landscape nocenter; ods printer pdf file="../Variables.pdf" ; ****orient=landscape; /* proc template; %include '/pub/sascode/osedablue.sas'; *<====Optional style thing===; run; */ ods html file='../Variables.html' contents='../VariablesContent.html' style=osedablue; ods listing close; proc print data=sf3x.Variables label; where pctflag=0 or UnivVar=' '; *<--do not show the Pct variables unless they are stand-alone--; by table notsorted universe notsorted; id name; var label--comment UnivVar WtVar; format label $char.; title 'Metadata for the sf32000x Filetype (Partial listing of Variables dataset)'; footnote 'Note: Universe Variable is denominator used to create corresponding Pct Variable'; title2 "Revised as of &sysdate &systime"; run; ods printer close; ods html close; %end; libname sf3 clear; libname sf3x clear; %mend cnvtmeta; **options source2; /* ========================begin comment==================================== %let setin=mo; %cnvtmeta(meta) ; options nosource2; %cnvtmeta(data) ; run; data _null_; file stdout; put 'Missouri conversions complete'; run; %let setin=ks; %cnvtmeta(data) ; run; data _null_; file stdout; put 'Kansas conversions complete'; run; %let setin=il; %cnvtmeta(data) ; run; data _null_; file stdout; put 'Illinois conversions complete'; run; %let setin=mi; %cnvtmeta(data) ; run; data _null_; file stdout; put 'Michigan conversions complete'; run; %let setin=mn; %cnvtmeta(data) ; run; data _null_; file stdout; put 'Minnesota conversions complete'; run; ==========================end comment====================================== */ *---This id NOT work! We did not have the ky sf3 data sets---*; %let setin=ky; %cnvtmeta(data) ; run; data _null_; file stdout; put 'Kentucky conversions complete'; run;