x cd /pub/data/acs2009/Tools; %let pgm=edit_tsadata; filename pgm "&pgm..sas"; *---Edit the dataset created by Billy Earney, breaking it into separate sets and editing various ID vars. Also, we shall be moving all the moe vars to the end of the observations. Then users can easily select variables without having to deal with MOEs (which are calculated on these data sets and thus not necessarily reliable. ---*; *---test moelist macro---; libname acs2009 '/pub/data/acs2009'; *---This macro invocation will define the global var tsamoes with a list of all the _moe vars on the specified data set--; %moelist(acs2009.tsamcdcprofiles5yr,listvar=tsamoes); *---this step creates the temp dataset tsanew with all the moe vars moved to the end of the observations----; %movevars(acs2009.tsamcdcprofiles5yr,tsanew,varlist=tsamoes); data acs2009.motsaprofiles (label='MO Tract-Based Statistical Area (TSA) Summaries for Selected Areas') acs2009.ohtsaprofiles (label='Cleveland, OH Tract-Based Stat Area Summaries'); set tsanew (drop=geocomp geocomp_name placefp cbsa metrodiv); datecreated=today(); state=substr(geoid,8,2); puma=substr(geoid,10,3); *--the columbia geos are tract based statistical areas with 2-char codes unique within PUMA. In the St Louis metro area we have the TRA geos which do not nest within PUMAs and have 4-character TRA codes. ---; length tbsa $2 tra $4; if puma='006' then do; puma='00600'; County='29019'; ***tbsa=substr(geoid,15,4); end; else if state ne '39' then do; tbsa=substr(geoid,13,2); tra=substr(geoid,13,4); if puma in('015','019') then substr(puma,4,2)='00'; else substr(puma,4,2)='XX'; if puma='01500' then select (tra); when ('WASH','FARW','UNPA','SFRA') county='29071'; WHEN ('TROY','SELN') COUNTY='29113'; WHEN ('WARN') COUNTY='29219'; END; else if puma='016XX' then county='29183'; else if puma='017XX' then county='29189'; else if puma='018XX' then county='29510'; else if puma='01900' then county='29099'; end; else TBSA=substr(geoid,13); if tra ne ' ' then areaname=trim(areaname)||' TRA'; else if state ='29' then areaname=trim(areaname)||' TBSA'; else areaname=trim(areaname)||' SPA'; if state='39' then output acs2009.ohtsaprofiles; else output acs2009.motsaprofiles; format areaname geoid; run; proc print data=acs2009.motsaprofiles(keep=_character_ datecreated totpop); by datecreated years period sumlev state; title2 'Character Vars in acs2009.ohtsaprofiles'; id geoid; run; proc print data=acs2009.ohtsaprofiles(keep=_character_ totpop); by years period sumlev state; title2 'Character Vars in acs2009.ohtsaprofiles'; id geoid; run;