I used ODS Graphics Designer to create my desired plot. I want to make that plot into a macro so I can create it for each individual subject. I get the following note: "The graph uses multiple datasets. This is not supported by PROC SGRENDER. You need to run PROC SGDESIGN to generate the graph."
I am unfamiliar with both PROC TEMPLATE and PROC SGDESIGN, so I am unsure if I am going about creating this macro the right way.
I am trying to create a macro from the following:
%macro ind_plot(id, /*unique subject ID*/
param, /*antibody parameter code*/
ab, /*antibody type for file name*/
T2, T27, /*CHMI 2 treatment day and 7-days post treatment*/
T3, T37, /*CHMI 3 treatment day and 7-days post treatment*/
T4, T47, /*CHMI 4 treatment day and 7-days post treatment*/
T1= 30, T17= 37 /*CHMI 1 treatment day and 7-days post treatment >> for missing treatment days, give value out of range*/
);
data chmi1 (where= (aphasen = 1)) chmi2 (where= (aphasen = 2)) chmi3 (where= (aphasen = 3)) chmi4 (where= (aphasen = 4));
set _have_;
where usubjid = "&id." and paramcd = "¶m." and phady > 0;
run;
/* The graph uses multiple datasets. This is not supported by PROC SGRENDER. You need to run PROC SGDESIGN to generate the graph. */
proc template;
define statgraph Graph;
dynamic _PHADY2 _CHG2 _PHADY _CHG _PHADY3 _CHG3 _PHADY4 _CHG4;
begingraph / designwidth=937 designheight=592;
entrytitle halign=center "Subject &id." / textattrs=(family='Times New Roman' );
layout lattice / rowdatarange=union columndatarange=data columns=4 rowgutter=10 columngutter=10 columnweights=(1.0 1.0 1.0 1.0);
rowaxes;
rowaxis / label=('Antibody Reactivity (Baseline-adjusted OD410)') labelattrs=(family='Times New Roman' ) tickvalueattrs=(family='Times New Roman' ) linearopts=( viewmin=-1.0 viewmax=2.5 tickvaluesequence=( start=-1.0 end=2.5 increment=0.5));
endrowaxes;
layout overlay / xaxisopts=( display=(TICKS TICKVALUES LINE LABEL ) griddisplay=off label=('Actual CHMI Day') labelattrs=(family='Times New Roman' ) tickvalueattrs=(family='Times New Roman' ) linearopts=( tickvaluepriority=TRUE tickvalueformat=BEST12. tickvaluelist=(1.0 6.0 8.0 &T1 &T17) tickdisplaylist=("1" "6" "8" "T" "T+7"))) yaxisopts=( display=(TICKS TICKVALUES LINE LABEL ) label=('Antibody Reactivity (Baseline-adjusted OD410)') labelattrs=(family='Times New Roman' ) tickvalueattrs=(family='Times New Roman' ) linearopts=( minorticks=OFF tickvaluesequence=( start=-1.0 end=2.5 increment=0.5)));
seriesplot x=_PHADY y=_CHG / name='CHMI 1' display=(markers) groupdisplay=Cluster connectorder=xaxis markerattrs=GraphData1(color=CX000000 );
endlayout;
layout overlay / xaxisopts=( display=(TICKS TICKVALUES LINE LABEL ) label=('Actual CHMI Day') labelattrs=(family='Times New Roman' ) tickvalueattrs=(family='Times New Roman' ) linearopts=( viewmin=1.0 viewmax=25.0 tickvaluepriority=TRUE tickvalueformat=BEST12. tickvaluelist=(1.0 6.0 8.0 &T2 &T27) tickdisplaylist=("1" "6" "8" "T" "T+7")));
seriesplot x=_PHADY2 y=_CHG2 / name='CHMI 2' display=(markers) connectorder=xaxis;
endlayout;
layout overlay / xaxisopts=( griddisplay=off label=('Actual CHMI Day') labelattrs=(family='Times New Roman' ) tickvalueattrs=(family='Times New Roman' ) linearopts=( viewmin=1.0 viewmax=25.0 tickvaluepriority=TRUE tickvalueformat=BEST12. tickvaluelist=(1.0 6.0 8.0 &T3 &T37) tickdisplaylist=("1" "6" "8" "T" "T+7")));
seriesplot x=_PHADY3 y=_CHG3 / name='CHMI 3' display=(markers) connectorder=xaxis;
endlayout;
layout overlay / xaxisopts=( griddisplay=off label=('Actual CHMI Day') labelattrs=(family='Times New Roman' ) tickvalueattrs=(family='Times New Roman' ) linearopts=( viewmin=1.0 viewmax=25.0 minorticks=OFF tickvaluepriority=TRUE tickvalueformat=BEST12. tickvaluelist=(1.0 6.0 8.0 &T4 &T47) tickdisplaylist=("1" "6" "8" "T" "T+7")));
seriesplot x=_PHADY4 y=_CHG4 / name='CHMI 4' display=(markers) connectorder=xaxis;
endlayout;
endlayout;
endgraph;
end;
run;
*****Need help with SGDESIGN code*****;
proc sgdesign png= "Fig_immuno_ind_&ab._&id.";
data= _work_;
run;
%mend ind_plot;
*%ind_plot(id, param, ab, T2, T27, T3, T37, T4, T47, T1= 30, T17= 37);
%ind_plot(id= ABC, param= CSPIG, ab= CSP_IgG, T2= 14, T27= 21, T3= 12, T37= 19, T4= 17, T47= 24);
Mock Data:
data _have0_;
input id $ param $ aphasen phady chg @@;
cards;
ABC CSPIG 1 1 -0.15
ABC CSPIG 1 2 -0.20
ABC CSPIG 1 4 -0.21
ABC CSPIG 1 6 -0.01
ABC CSPIG 1 8 -0.16
ABC CSPIG 1 9 0.05
ABC CSPIG 1 10 0.21
ABC CSPIG 1 11 0.25
ABC CSPIG 1 12 1.02
ABC CSPIG 1 14 1.05
ABC CSPIG 1 15 1.19
ABC CSPIG 1 16 1.39
ABC CSPIG 1 17 1.86
ABC CSPIG 1 20 1.90
ABC CSPIG 1 21 1.68
ABC CSPIG 1 22 1.36
ABC CSPIG 1 24 1.12
;
data _have_;
set _have0_; output;
set _have0_; aphasen= 2; chg= chg + 0.9; output;
set _have0_; aphasen= 3; chg= chg - 0.03; output;
set _have0_; aphasen= 4; chg= chg/2 + 1; output;
run;
... View more