x cd /pub/data/sf12000x/Tools; %let pgm=cnvt_sf12000x; filename pgm "&pgm..sas"; *----Accesses a sf12000 (complete 2000 SF1) type data set and creates (1 or more) sf12000x standard extract files (as used in generating our DT2K-1 Demographic Trend Report 1: 1990-2000) data products. Shiva Kumar and John Blodgett, Initial coding June, 2001. Revision History: 6-28-01: Variable asian1 was labeled as "Asian only" but was in fact the sum of Asians and Pac Islanders. We change this so that they are really just Asians. 6-30-01: Making it a macro (doit) with more flexibility for specifying 1990 data options. ----*; options msglevel=i fullstimer; libname sf12000 '/pub/data/census_2000/sf12000' access=readonly; libname sf12000x '/pub/data/sf12000x'; libname sf1 (sf12000); *--alternate libref--; libname sf1x (sf12000x); *--alternate libref--; %libname(sf1prof); %libname(stf901x2,opts=); *<---custom generated 1990 stf1 extract set ready to be merged with our sf2000x data set-; *libname user '/SAS_temp/user'; /* ******Specifications for this filetype******* 1. Very similar to the Census Bureau DT-1 Demographic Profile product (released as pdf and CSV files for govt. units in May, 2001. See filetype sf1prof. 2. All variable names should be the same as the corresponding items in data sets in the sf1prof datasets if they are present there. This data set is a superset of the sf1prof filetype. 3. Verify that output matches those published in DT-1 reports by Census Bureau. Very important that we be consistent with that product/standard. ******************************** */ *----Generate attrib statements describing the variables on an sf1prof data set. The resulting sas code will be included in the data step below.---; *filename attrib 'sf1prof_attrib.sas'; *genattr(setin=sf1prof.us,debug=1); *-------We bring in this file and edit in-line as part of the conversion data step.------; %macro doit(state,stab,set90=,iset=1,hset=0,bset=0,step1=1,contents=0); %*--this macro handles the standard case for a single state. It does not work for special aggregations-; %let ustab=%upcase(&stab); %if &step1 %then %do; %*<--For reruns specify step1=0 to avoid regenerating user._2000&stab data set; data _2000&stab; length default=5; length esriid $42.; merge sf1.&stab.geos sf1.&stab.phng sf1.&stab.pctng ; by geo_id; %include '/pub/sascode/sf12000x.sas'/source2; keep sumlev geo_id geocode geocomp state stab areaname county tract bg block cousubfp placefp areasqmi landsqmi intptlon intptlat esriid; *--these ids are kept in addition to all the extract vars as specified in the included sas code--; run; proc sort data =_2000&stab; by sumlev geocode; run; %end; %*<==========Step 1 code; %let keep90= %str(keep=sumlev geocode state totpop rename=(totpop=totpop90) ); *<============NOTE: This section of code may need to be edited per the specific geographic area being converted==; data %if &iset %then %str( sf12000x.&stab.i(label="Std extract fr sf1 data for &ustab + 90 Pop - Inventory summaries") ); %if &hset %then %str( sf12000x.&stab.h(label="Std extract fr sf1 data for &ustab + 90 Pop - Hierarchal summaries") ); %if &bset %then %str( sf12000x.&stab.blks(label="Std extract fr sf1 data for &ustab + 90 Pop - Block summaries") ); ; merge _2000&stab(in=in2k) %if &set90=us %then %do; stf901x2.us (where=(state="&state") &keep90 in=in90i); %end; %else %if &iset %then %do; stf901x2.&stab.i ( &keep90 in=in90i) %end; %if &bset %then %do; stf901x2.&stab.blks ( &keep90 in=in90b) %end; %if &hset %then %do; stf901x2.&stab.h ( &keep90 in=in90h) %end; ; by sumlev geocode; if in2k; if in90i %if &hset %then %str( or in90h ); %if &bset %then %str( or in90b ); then do; change=totpop - totpop90; if totpop90 then pctchange=100*change/totpop90; end; if sumlev='101' then %if &bset %then %str( output sf12000x.&stab.blks;); %else %str( delete;); else if sumlev in ('070','080','091') then %if &hset %then %str( output sf12000x.&stab.h; ); %else %str( delete;); else output sf12000x.&stab.i; run; %if &contents %then %do; proc contents data=sf1x.&stab.i position; run; %end; %mend doit; /*<=========================Comment out===================================== %doit(29,mo,step1=1); %doit(20,ks,step1=1); %doit(17,il,step1=1); ===========================End commented out================================ */ *=========================Convert Missouri School District Data sets===========================*; data sf12000x.moschls; merge sf1.moschlsph sf1.moschlcosph; ****Need a 90 data set source here***; by geocode; if in2k; ************************Begin here********************************************* if in90i %if &hset %then %str( or in90h ); %if &bset %then %str( or in90b ); then do; change=totpop - totpop90; if totpop90 then pctchange=100*change/totpop90; end; run;