x cd /pub/data/sf32000x/Tools; %let pgm=cnvtsf3x_molibdists; 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. Unlike more generic setup this one runs for a custom geography -- the mo library district summaries.--; John Blodgett, OSEDA, U. of Missouri Outreach & Extension. Under contract with the Missouri Census Data Center. Jan, 2003 ---*/ %let setin=molibdists; %let dvmode=data; *--required by dovar macro which is invoked dozens of times by the invoke_dovars module--; title "&pgm: Create sf32000x Extract Datasets from sf32000 Datasets"; *----the dovar macro is where the work is actually done. Below, the cnvtmeta macro serves as the "driver" which invokes this macro one per variable. It gets run once in data more and once in meta mode--; *include '/pub/sasmacro/dovarsf3.sas'; *---contains the dovars macro-------------------; libname sf3 "/pub/data/sf32000" access=readonly; libname sf3x "/pub/data/sf32000x"; *----the dovar macro is where the work is actually done. Below, the included invoke_dovars.sas serves as the "driver" which invokes this macro once per variable. It gets run once in data mode only here---; options NOmprint; *---------Here is the conversion data step-------------*; data sf3x.molibdists (label='Missouri Library District (complete) Summaries') sf3x.molibdistcos(label='Missouri Library District within county Summaries'); length default=5 Obs 5 esriid $3 distcode $3; merge sf3.&setin.ph sf3.&setin.phct(in=inct); * by logrecno; *-----No key used -- we merge obs by obs, dangerous!!!!!!!!!!!!!!!!!!!!---; label esriid='Id field to link to ESRI map files'; %include 'invoke_dovars.sas'/source2; *<---------here is where the data is defined---; esriid=compress(geocode,'-.'); grcid=esriid; if sumlev = 'lib' then do; _obs1+1; Obs=_obs1; output sf3x.molibdists; end; else do; _obs2+1; Obs=_obs2; output sf3x.molibdistcos; end; label grcid='Id field to link to GRC/MsDIS map files (Mo only)'; keep Obs esriid geocode distcode sumlev areaname county partflag; keep TotPop -- grcid; label Obs='Observation #'; run; run; proc print data=sf3x.molibdists(obs=100); title2 'First 100 Obs from sf3x.molibdists: MO Library Districts'; by SumLev notsorted; id sumlev; var geocode esriid distcode areaname totpop; run; proc print data=sf3x.molibdistcos(obs=100); title2 'First 100 Obs from sf3x.molibdistcos: Within-county Library Districts'; ; by SumLev; id geocode; var esriid distcode areaname totpop partflag county; format county $5.; run;