x cd /pub/data/sf32000x/Tools; %let pgm=cnvtsf3x_moschls; 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 school district summaries.--; John Blodgett, OSEDA, U. of Missouri Outreach & Extension. Under contract with the Missouri Census Data Center. Revised (initial) version 9.04.02. Rerun 9-12-02 after fix to hhinc35 and hhinc50 variables. Rerun 9-30-02 after fix to hhinc50 and hval300 vars. Rerun 12-10-02 to add desedist code. Rerun 3-26-03 to fix desedist codes and to omit the 99998 codes and the 99999 code for sde. Rerun 5-20-04 after fix to under18. ---*/ %let setin=moschls; %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"; libname sf3 "/pub/data/sf32000" access=readonly; libname sf3x "/pub/data/sf32000x"; options NOmprint; *---------Here is the conversion data step-------------*; data sf3x.moschls (label='Missouri School District (complete) Summaries') sf3x.moschlcos(label='Missouri School District within county Summaries'); length default=5 Obs 5 esriid $16 desedist $6; merge sf3.&setin.ph sf3.&setin.phct(in=inct); * by logrecno; *---these 2 filters added 3-26-03---; if ncescode='99998' then delete; if ncescode='99999' and sumlev in ('sde','se2') then delete; *-----No key used -- we merge obs by obs, dangerous!!!!!!!!!!!!!!!!!!!!---; label esriid='Id field to link to ESRI map files'; %include 'invoke_dovars.sas'/source2; esriid=compress(geocode,'-.'); grcid=esriid; desedist=put(ncescode,$schcnvt.); if sumlev in ('sdu','sde') then do; _obs1+1; Obs=_obs1; output sf3x.moschls; end; else do; _obs2+1; Obs=_obs2; output sf3x.moschlcos; end; label grcid='Id field to link to GRC/MsDIS map files (Mo only)'; keep Obs esriid geocode ncescode desedist sumlev areaname county partflag; keep TotPop -- grcid landsqmi;; label Obs='Observation #'; run; *----Create 3 views for sdunis, sdelms and schlcos----; proc sql; create view sf3x.mosdunis as select * from moschls where sumlev ='sdu'; create view sf3x.mosdelms as select * from moschls where sumlev ='sde'; quit; run; proc print data=sf3x.moschls(obs=100); title2 'First 100 Obs from sf3x.mosdelms: Complete Elementary School Districts'; by SumLev notsorted; id sumlev; var geocode esriid ncescode desedist areaname totpop; run; proc print data=sf3x.moschlcos(obs=100); title2 'First 100 Obs from sf3x.moschlcos: Within-county Unified and Elementary Districts'; ; by SumLev; id geocode; var esriid ncescode desedist areaname totpop partflag county; format county $5.; run;