BookmarkSubscribeRSS Feed
echoli
Obsidian | Level 7

Hi All,

 

I wrote a dynamic template to draw scatter plots, but I want to add coefficient and p value into the figure. The coefficient and p value can be anywhere in the figure. Like what I did now, it's above the figure, but I insert the values manually one by one. Any idea to input then quickly? my goal is just show the values in the figure, I don't care the type, the location or some other things. I just don't want input manually. Below is my template.Code with bold are what I want to change.

 

proc template;
/* Create the plot template. */
define statgraph testPattern;
begingraph / designheight = 8in;
dynamic var1 var2 var3;
layout lattice / columns = 1 rows = 2 rowgutter = 20 columngutter = 20;
/* */
cell;
cellheader;
layout gridded / border = true;
entry "Toddler S = 0.518 p = <.001; Young S = 0.383 p = <.001" / textattrs = (weight = bold);
entry "Child S = 0.428 p = <.001; Teen S = 0.383 p = <.001" / textattrs = (weight = bold);
endlayout;
endcellheader;
layout overlay / yaxisopts = (label = var1 labelattrs = (weight = bold size = 8pt) tickvalueattrs = (weight = bold))
xaxisopts = (label = var3 labelattrs = (weight = bold) tickvalueattrs = (weight = bold));
scatterplot y=var1 x=var3 / group=group;
regressionplot y=var1 x=var3 / group = group name="lines";
discretelegend "lines";
endlayout;
endcell;
cell;
cellheader;
layout gridded / border = true;
entry "Toddler S = 0.517 p = <.001; Young S = 0.383 p = <.001" / textattrs = (weight = bold);
entry "Toddler S = 0.377 p = <.001; Young S = 0.318 p = 0.002" / textattrs = (weight = bold);
endlayout;
endcellheader;
layout overlay / yaxisopts = (label = var2 labelattrs = (weight = bold size = 8pt) tickvalueattrs = (weight = bold))
xaxisopts = (label = var3 labelattrs = (weight = bold) tickvalueattrs = (weight = bold));;
scatterplot y=var2 x=var3 / group=group;
regressionplot y=var2 x=var3 / group=group name="lines";
discretelegend "lines";
endlayout;
endcell;
endlayout;
endgraph;
end;
run;
/* Generate the plot. */
options orientation=landscape;
ods rtf file="scattertest1.rtf";

proc sgrender data=combine template='testPattern';
dynamic var1 = 'P_SCD_SCORE_PH' var2 = 'P_SCD_SCORE_PI' var3 = 'P_SCD_SCORE_PMC';
run;
ods rtf close;scatter plot.png

4 REPLIES 4
ballardw
Super User

Looks like you may want more dynamic variables

echoli
Obsidian | Level 7

Yes, that a method. But as you can see, in the two entrys statement, I need 8 dymanic variables, and these variables are in another dataset which I run out. I thought there maybe have simpler way to add coefficient and p value in the graph.

 

Thanks,

C

djrisks
Barite | Level 11

Hi C,

 

I would use into: with proc sql to obtain the pvalues.

 

And then use the nmvar or mvar statement to plot those p-values. So it's quite similar to what you've done already, but instead of manually entereing the numbers, the numbers are already in a macro variable.

 

Also you don't have to use the nmvar or mvar statement.

 

You could also just use something like this:

 

entry "Toddler S = 0.518 p = &pvalue1; Young S = 0.383 p = &pvalue2" / textattrs = (weight = bold);

 

After creating the pvalue1 and pvalue2 macro variables.

 

The code in this paper shows how I've created macro variables with the into clause and then displayed those values on the plot.

 

http://support.sas.com/resources/papers/proceedings13/243-2013.pdf

 

Many thanks,

 

Kriss  

djrisks
Barite | Level 11

Hi C,

 

I would use into: with proc sql to obtain the pvalues.

 

And then use the nmvar or mvar statement to plot those p-values. So it's quite similar to what you've done already, but instead of manually entereing the numbers, the numbers are already in a macro variable.

 

Also you don't have to use the nmvar or mvar statement.

 

You could also just use something like this:

 

entry "Toddler S = 0.518 p = &pvalue1; Young S = 0.383 p = &pvalue2" / textattrs = (weight = bold);

 

After creating the pvalue1 and pvalue2 macro variables.

 

The code in this paper shows how I've created macro variables with the into clause and then displayed those values on the plot.

 

http://support.sas.com/resources/papers/proceedings13/243-2013.pdf

 

Many thanks,

 

Kriss  

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1327 views
  • 0 likes
  • 3 in conversation