x cd /pub/data/mable09/Tools; %let pgm=genmable2k_09; filename pgm "&pgm..sas"; %include '/pub/sas/autoexec.sas'; libname m09in '/pub/data/mable09'; libname m09out '/pub/data/mable09'; libname temp '/pub/data/mable09/temp'; /* proc datasets nolist; copy in=m09in out=temp override=(encoding=session outrep=session); select akcocds2 cococds2 vacocds2; run; data m09out.akcocds2(label="More county based codes including 2003 cbsas" index=(county) outrep=LINUX_X86_64); length cbsa metrodiv county cbsatype cbsayr $4; length csa $3; length state ui_code $2; length beale93 beale03 $1; set temp.akcocds2; run; data m09out.cococds2(label="More county based codes including 2003 cbsas" index=(county) outrep=LINUX_X86_64); length cbsa metrodiv county cbsatype cbsayr $4; length csa $3; length state ui_code $2; length beale93 beale03 $1; set temp.cococds2; run; data m09out.vacocds2(label="More county based codes including 2003 cbsas" index=(county) outrep=LINUX_X86_64); length cbsa metrodiv county cbsatype cbsayr $4; length csa $3; length state ui_code $2; length beale93 beale03 $1; set temp.vacocds2; run; */ %let popestyr=09; *<----controls what uscom data set we access and what popjlXX estimate we use---------; %let yy=09; %let mableyy=mable09; *<===; %let mablepath=%str(/pub/data/mable09); libname mable2k "&mablepath"; libname &mableyy "/pub/data/mable&yy"; *<-------------This is where we write-------------; title "&pgm.: Generate the Vingtage 2006 Mable Database"; options mprint; %macro doit(state,stab); proc sort force data=&mableyy..&stab.blks07; by county; run; proc sort force data=mable2k.&stab.cocds1; by county; run; proc sort force data=mable2k.&stab.cocds2; by county; run; data mable2k.&stab.cocds2 (index=(county)); set mable2k.&stab.cocds2; run; data &mableyy..&stab.v3(label="All variables for &stab rev. to 08")/view=&mableyy..&stab.v3; *---this is the defn of the view that combines all the real datasets---; set &mableyy..&stab.blks07; by county; county02=county; *---recode here is for the 2 cases in Virginia and Colorado, where county defns have changed since 2000--; if county='51560' then county02='51005'; else if state='08' and placefp='09280' then county02='08014'; else if state='02' and county='02232' then do; if placefp='70760' then county02='02230'; else county02='02105'; end; if first.county then do; set mable2k.&stab.cocds1(%if &state=29 %then %str( keep=state--cohus2k ); rename=(county=countyck)); %if &state ne 08 and &state ne 51 and &state ne 02 %then %do; set &mableyy..&stab.cocds2(rename=(county=countyck2)); %end; end; %if &state=08 or &state=51 or &state=02 %then %do; _save=county; drop _save; county=county02; %*--do keyed read on the cocds2 set using county02 as key--; if county ne lag(county) then set &mableyy..&stab.cocds2 key=county; if _iorc_ then do; put "*****ERROR doing keyed read of &stab.cocds2 dataset for county " county $5. +1 county $county. ; _error_=1; end; county=_save; countyck2=county; %end; if cbsa='99999' then cbsa=' '; if county ne countyck then do; put "*************Error: county code on &stab.cocds1 dataset does not match that on the blks datasets****"; abort 600; end; if county ne countyck2 then do; put "*************Error: county code on &stab.cocds2 dataset does not match that on the blks datasets****"; abort 601; end; drop countyck countyck2; format county $5.; run; proc print data=&mableyy..&stab.v3 (obs=40); by state stab cnty; id tract block; title2 "Some Observations from &mableyy..&stab.v3 (View with revised geocodes)"; run; proc means maxdec=0 n sum data=&mableyy..&stab.v3; *---This step tests the view because it looks at entire set-; class state county cd109 sldl02 sldu02 cd109 cbsa csa beale03 ui_code / missing; var pop2k ; types state county cd109 sldu02 cbsa csa beale03 ui_code ; title2 'Some Proc Means summaries for various geographies'; run; data &mableyy..&stab.v4 (index=(county)); set &mableyy..&stab.v3; run; %mend doit; options NOmprint; /*<=========================Comment out===================================== *----custom run for Alaska only to try and get around problems caused by splitting of a Census Area (county equivalent) in 2008 estimate year. redefine the Alaska blocks. ----; %**doit(02,ak) *---Special run to fix cd108 variable for Parke County, IN-----*; data mable09.inblks07edited; set mable09.inblks07; if county='18121' and cd108=' ' then cd108='08'; run; ==========================end comment====================================== */ %*dostates(02); %*dostates(08); %dostates(51);