%macro coplot5(data,x,y,panelvar); proc univariate data=&data noprint; var &panelvar; output out=Pctls pctlpts=20 40 60 80 pctlpre=P_ pctlname=P20 P40 P60 P80; run; proc print;run; data _null_; set Pctls; call symput('P20',left(put(P_P20,best10.))); call symput('P40',left(put(P_P40,best10.))); call symput('P60',left(put(P_P60,best10.))); call symput('P80',left(put(P_P80,best10.))); run; data z_coplot; set &data; pctile=' 0_20'; if &panelvar>&P20 then pctile=' 20_40'; if &panelvar>&P40 then pctile=' 40_60'; if &panelvar>&P60 then pctile=' 60_80'; if &panelvar>&p80 then pctile='80_100'; run; title Coplot of 'x Variable' &x ', y Variable' &y ', Grouped by' &panelvar 'Percentiles'; proc sgpanel data=z_coplot; panelby pctile/rows=1 columns=5; scatter x=&x y=&y; run; title Coplot with Loess of 'x Variable' &x ', y Variable' &y ', Grouped by' &panelvar 'Percentiles'; proc sgpanel data=z_coplot; panelby pctile/rows=1 columns=5; loess x=&x y=&y; run; title ' '; %mend coplot5; %coplot5(ma2612.eg8_1,z2,y1,z1); %coplot5(ma2612.eg8_1,z1,y1,z2);