BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mariko5797
Pyrite | Level 9

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 = "&param." 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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
mariko5797
Pyrite | Level 9
%macro ind_plot(id, param);
	data chmi1 (where= (aphasen = 1)) chmi2 (where= (aphasen = 2)) chmi3 (where= (aphasen = 3)) chmi4 (where= (aphasen = 4));
	 set _have_;
	 where usubjid = "&id." and paramcd = "&param." and phady > 0;
	run;

	proc sgdesign sgd= '<pathway>'; run;
%mend;

Proc SGDesign does not need data specified.

View solution in original post

3 REPLIES 3
DanH_sas
SAS Super FREQ

PROC SGDESIGN is a procedure that that takes the ODS Graphics Designer save file (<filename>.sgd) as input to generate the graph from a SAS program. The SGD file maintains references to the data sets such that, if the data updates, the regenerated graph will also be updated. In your case, you must have built the graph using multiple data sources, which is why you must use PROC SGDESIGN. PROC SGRENDER (used to render GTL templates) can take only one "primary" data set (not including annotation and attribute maps data sets). The key item for PROC SGDESIGN is that you will need to keep the SGD file(s) where you can access them from your SAS session. The documentation should cover the procedure options, but let.me know if you have any questions about the procedure.

 

Hope this helps!

Dan

mariko5797
Pyrite | Level 9
How do you get proc sgdesign to read from multiple datasets?
mariko5797
Pyrite | Level 9
%macro ind_plot(id, param);
	data chmi1 (where= (aphasen = 1)) chmi2 (where= (aphasen = 2)) chmi3 (where= (aphasen = 3)) chmi4 (where= (aphasen = 4));
	 set _have_;
	 where usubjid = "&id." and paramcd = "&param." and phady > 0;
	run;

	proc sgdesign sgd= '<pathway>'; run;
%mend;

Proc SGDesign does not need data specified.

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1014 views
  • 2 likes
  • 2 in conversation