x cd /mscdc/sas/formats/Tools; %let pgm=chkmetro; filename pgm "&pgm..sas"; *--Check the $metro format code to identify entries that are missing or where we do not have any current data for them. jgb, 11-98--; %libname(popests,casrh97); libname user '/tmp/storage/user'; /* *<===============COMMENT OUT================================= ====================================================== */ *---1: Generates set with unique metro area codes for latest year---*; data mcodes; set casrh97.ushl9097(keep=slvl msacmsa pmsa mtype areaname year racehsex); where year='1997' and racehsex='---'; if mtype='P' then mcode=pmsa; else mcode=msacmsa; keep mcode mtype areaname; run; proc sort out=mcodesu nodupkeys; by mcode mtype; run; *---2: grab codes in current format.-----*; options obs=999; *<====to prevent stupid runaways where select statement is ignored---; proc format library=library.formats cntlout=fmcodes(keep=start label); select $metro; run; options obs=max; data sortin/view=sortin; length mcode $4 mtype $1; set fmcodes; mcode=start; if index(label,'(P)') then mtype='P'; else if index(label,'(C)') then mtype='C'; else if index(label,'(N)') then mtype='N'; else mtype='M'; drop start; run; proc sort data=sortin out=curmcods; by mcode mtype; run; *---3: compare the 2 sets of codes and create a discrepancy set---; data tocheck; merge mcodesu(in=innew) curmcods(in=inold); by mcode mtype; if not (innew and inold) then do; if not innew then do; if index(label,'-X') then delete; status='Not in estimates file'; end; else status='Not in format'; output; end; run; proc sort; by status; run; proc print data=tocheck n u; by status; id mcode mtype ; title2 'Report Showing Metro Area Codes Not on Both Sets'; run;