/**********************************************************************/ data rainfall; input @1 city $13. @15 rainfall 4.2 @20 qtr 1.; cards; Asheville 8.2 1 Asheville 9.1 2 Asheville 10.2 3 Asheville 9.1 4 Charlotte 11.3 1 Charlotte 8.7 2 Charlotte 8.9 3 Charlotte 10.5 4 Raleigh 5.2 1 Raleigh 5.1 2 Raleigh 9.5 3 Raleigh 8.6 4 Greensboro 11.2 1 Greensboro 11.1 2 Greensboro 9.2 3 Greensboro 7.6 4 Winston_Salem 10.9 1 Winston_Salem 10.5 2 Winston_Salem 9.1 3 Winston_Salem 8.7 4 run; /**********************************************************************/ proc sort data=rainfall; by city rainfall; run; /**********************************************************************/ data rainfall; set rainfall end=eof; by city; retain i o; if first.city then do; i=i+1; call symput('start'||left(i),rainfall); call symput('city'||left(i),trim(city)); call symput('first'||left(i),_n_); end; else if last.city then do; call symput('stop'||left(i),rainfall); call symput('last'||left(i),_n_); end; if eof then call symput('tot',i); run; /**********************************************************************/ %macro chartit(dsn=,chrtvar=,sumvar=,grpvar=); %do i=1 %to &tot; proc chart data=&dsn(firstobs=&&first&i obs=&&last&i); block &chrtvar / sumvar=&sumvar group=&grpvar axis=&&start&i &&stop&i; title "Rainfall Amount for &&city&i by Quarter"; format &sumvar 4.1; run; %end; %mend chartit; /**********************************************************************/ %chartit(dsn=rainfall,chrtvar=city,sumvar=rainfall, grpvar=qtr) /**********************************************************************/