%macro docos(state=29,cos=,mac=doit,names=0,msgs=0, revdate=05Mayv02); %*--does for counties what dostates does for states, at least when it is done we expect it to do that-; %*--Coding begins 5-5-02, jgb-; %local counties cnames i ncos county cnytname; proc format library= library.formats cntlout=cocodes(keep=start label where=(county=:"&state" and length(county)=5 %if &cos ne %str() %then %do; and index("&cos",trim(county)) %end; and substr(county,3,3) ne '000') rename=(start=County label=CntyName)); select $county; run; proc sql noprint; select County into :counties separated by ' ' from cocodes; %if &names %then %do; select CntyName into :cnames separated by '|' from cocodes; %end; %else %let cntyname=%str(); quit; %let ncos=%lenlst(&counties); %do i=1 %to &ncos; %let county=%scan(&counties,&i); %if &names %then %do; %let cntyname=%scan(&cnames,&i,%str(|)); %end; %if &msgs %then %put ***Invoking &mac for county &county &cntyname; %&mac(&county,&cntyname); %end; %*--do i loop--; %mend docos;