select(SumLev); *---Assign the standardized Geographic Code to uniquely ID the geographic area--; when('010') geocode=' '; when('020') geocode=region; when('030') geocode=division; when('040') geocode=state; when('050') geocode=county; when('060') geocode=%concatd(county,cousubfp); when('070') geocode=%concatd(county,cousubfp,placefp); when('080') geocode=%concatd(county,cousubfp,placefp,tract); when('085') do; geocode=%concatd(county,cousubfp,placefp,tract,UrbanRur); Areaname = "Census Tract "||tract||" ("||TRIM(areaname)||" part)" ; end; when('090') geocode=%concatd(county,cousubfp,placefp,tract,UrbanRur,bg); when('067') geocode=%concatd(county,cousubfp,SubMCD); when('140') geocode=%concatd(county,tract); when('144') geocode=%concatd(county,tract,aianhhfp); when('150') geocode=%concatd(county,tract,bg); when('154') geocode=%concatd(county,tract,bg,aianhhfp); when('155') do; geocode=%concatd(county,placefp); *<===Override areaname to make it the name of the place rather than the county.To leave as-is delete this + next 4 lines; length _arg $7; _arg=state||placefp; drop _arg; areaname=put(_arg,$fplace.); if areaname=_arg then areaname='Place '||placefp; end; when('158') geocode=%concatd(state,placefp,cnty,tract); when('160') geocode=%concatd(state,placefp); when('170') geocode=%concatd(state,concit); when('172') geocode=%concatd(state,concit,placefp); when('250') geocode=aianhh; when('260') geocode=%concatd(aianhhfp,state); when('270') geocode=%concatd(aianhhfp,cnty); when('271') geocode=%concatd(aianhhfp,cnty,cousubfp); when('273') geocode=%concatd(aianhhfp,cnty,cousubfp,placefp); when('252') geocode=aianhh; when('262') geocode=%concatd(aianhhfp,state); when('272') geocode=%concatd(aianhhfp,cnty); when('275') geocode=%concatd(aianhhfp,cnty,cousubfp); when('276') geocode=%concatd(aianhhfp,cnty,cousubfp,placefp); when('254') geocode=aianhh; when('264') geocode=%concatd(aianhhfp,state); when('274') geocode=%concatd(aianhhfp,cnty); when('277') geocode=%concatd(aianhhfp,cnty,cousubfp); when('278') geocode=%concatd(aianhhfp,cnty,cousubfp,placefp); when('256','291','292') geocode=%concatd(aianhhfp,tract); when('258','293','294') geocode=%concatd(aianhhfp,tract,bg); when('251','253','255') geocode=%concatd(aianhhfp,aits); when('257') geocode=%concatd(aianhhfp,aits,tract); when('259') geocode=%concatd(aianhhfp,aits,tract,bg); when('290') geocode=%concatd(aianhhfp,aits,state); when('280','283','286') geocode=%concatd(state,aianhhfp); when('282','285','288') geocode=%concatd(state,aianhhfp,cnty); when('261','265','267') geocode=%concatd(state,aianhhfp,cnty,cousubfp); when('263','266','268') geocode=%concatd(state,aianhhfp,cnty,cousubfp,placefp); when('281','284','287') geocode=%concatd(state,aianhhfp,aits); when('230') geocode=%concatd(state,anrc); when('380') geocode=msacmsa; when('381') geocode=%concatd(msacmsa,state); when('382') geocode=%concatd(msacmsa,state,placefp); when('383') geocode=%concatd(msacmsa,state,cnty); when('384') geocode=%concatd(msacmsa,state,cousubfp); when('385') geocode=pmsa; when('386') geocode=%concatd(pmsa,state); when('387') geocode=%concatd(pmsa,state,cnty); when('388') geocode=%concatd(pmsa,state,cousubfp); when('370') geocode=necma; when('371') geocode=%concatd(necma,state); when('372') geocode=%concatd(necma,state,placefp); when('373') geocode=%concatd(necma,state,cnty); when('390') geocode=%concatd(state,msacmsa); when('391') geocode=%concatd(state,msacmsa,placefp); when('392') geocode=%concatd(state,msacmsa,cnty); when('393') geocode=%concatd(state,msacmsa,cnty,cousubfp); when('395') geocode=%concatd(state,msacmsa,pmsa); when('396') geocode=%concatd(state,msacmsa,pmsa,cnty); when('397') geocode=%concatd(state,msacmsa,pmsa,cnty,cousubfp); when('374') geocode=%concatd(state,necma); when('375') geocode=%concatd(state,necma,placefp); when('376') geocode=%concatd(state,necma,cnty); when('400') geocode=UA; *---the following 7 When clauses treat the SumLev pairs as equivalents. The only "difference" is the order of the variables. On a state level file 420 is State-UA, while on the national file it is UA-State. For assigning geocode, we treat them as the same and always put UA ahead of state.--; when('410','420') geocode=%concatd(UA,state); when('430','431') geocode=%concatd(UA,state,cnty); when('440','441') geocode=%concatd(UA,state,cnty,cousubfp); when('450','451') geocode=%concatd(UA,state,cnty,cousubfp,placefp); when('460','461') geocode=%concatd(UA,state,placefp); when('462','463') geocode=%concatd(UA,state,concit); when('464','465') geocode=%concatd(UA,state,concit,placefp); when('500') geocode=%concatd(state,cd106); when('510') geocode=%concatd(state,cd106,cnty); when('511') geocode=%concatd(state,cd106,cnty,tract); when('521') geocode=%concatd(state,cd106,cnty,cousubfp); when('531') geocode=%concatd(state,cd106,placefp); when('541') geocode=%concatd(state,cd106,concit,placefp); when('550','551','552') geocode=%concatd(state,cd106,aianhhfp); when('553','554','555') geocode=%concatd(state,cd106,aianhhfp,aits); when('850') geocode=zcta3; when('860') geocode=zcta5; when('851') geocode=%concatd(state,zcta3); when('852') geocode=%concatd(state,zcta3,cnty); when('871') geocode=%concatd(state,zcta5); when('881') geocode=%concatd(state,zcta5,cnty); otherwise do; if sumlev ne lag(sumlev) then do; _badsl+1; drop _badsl; if _badsl le 50 then put '**Unrecognized SUMLEV: ' sumlev; end; end; end; *--select group--; geocode=compress(geocode,' '); *---remove any blanks from geocode---;