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;
Looks like you may want more dynamic variables
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
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
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
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.