BookmarkSubscribeRSS Feed
Jest
Obsidian | Level 7

Hi, 

 

How can I get values (n sample size) on a gplot for each timepoint?

 

Below is my code:

 

goptions reset = all ;
axis1 order =(1 to 4 by 1) label= (a=90 'Year') minor=none;
axis2 order = (4.5 to 4.6 by 0.01) label = ('Natural Log of lsmeans MSE Scores') minor=none ;
symbol1 interpol=std2mjt v=none color=blue r=1 w=2 v=plus;
symbol2 interpol=std2mjt v=none color=red r=1 w=2;
proc gplot data=means1;
plot estimate*year=cd / haxis = axis1 vaxis=axis2; where cd~=.;
run;
quit; 

9 REPLIES 9
ballardw
Super User

the symbol statement for the would use the POINTLabel = option with "#varname": Pointlabel=("#sales") would label the displayed point with the value of the variable SAles associeated with that point.

 

 

Jest
Obsidian | Level 7

Thank you ballardw.

 

I tried the code below and it didn't work. any idea why?

 

goptions reset = all ;
axis1 order =(1 to 4 by 1) label= (a=0 'Year') minor=none;
axis2 order = (4.5 to 4.6 by 0.01) label = (a=95 'Mean Scores') minor=none ;
symbol1 interpol=std2mjt v=none color=blue r=1;
symbol2 interpol=std2mjt v=none color=red r=1;
symbol3 v=dot cv=black pointlabel=("#ratio" c=black position=top);
proc gplot data=data;
plot logscores*year=ratio/ haxis = axis1 vaxis=axis2; where ratio~=.;;
run;
quit;

Reeza
Super User

If you have the option to use SGPLOT this is much easer use either a TEXT or MARKERCHAR statement.

Jest
Obsidian | Level 7

thank you Reeza.

 

Is there an example code for the sgplot?

 

Many thanks!

Jest
Obsidian | Level 7

Hi Reeza,

 

Thanks for your help with this. However, I still have yet to figure out how to make the sample size for each time point appear on the plot.

I am using a longitudinal dataset over 4 years. The exposure is a binary variable measured at baseline and the outcome is continuous. sgplot didn't seem to work. 

 

I am using the following code, but it doesn't seem to take:

 

goptions reset = all ;
axis1 order =(0 to 4 by 1) label= (a=0 'Year') minor=none;
axis2 order = (4.5 to 4.6 by 0.1) label = (a=95 'Mean Scores') minor=none ;
symbol1 interpol=std2mjt v=none color=blue r=1;
symbol2 interpol=std2mjt v=none color=red r=1;
symbol3 v=dot i=none pointlabel=(position=top j=l "#ratio");
proc gplot data=means1;
plot estimate*year=ratio;
run;
quit;

 

any ideas?

 

 

Reeza
Super User

That's nice. Post sample data so we can actually run your code please. Or use a representative data set from SASHELP. 

 

Post the SGPLOT code that didn't appear to work. I don't have access to SAS GRAPH. 

 

Note: I'll move this post to the graphics forum so someone with access and expertise in SAS/GRAPH can help you if that's what you're choosing to use. SG Procedures produce better quality graphs, just as an FYI. 

Jest
Obsidian | Level 7

Hi Reeza, 

 

thanks for your response. 

I think I need to generate the sample size n similar to when I generate the lsmeans with the output statement when running the proc mixed...See example code below. any idea how to generate sample size n by group with the lsmeans ods output? I can then run the sgplot...I put in bold the code for the sample size with the sgplot...

 

Generating LSMeans proc mixed...

 

ods output LSMeans=means1;
proc mixed data=data NOCLPRINT;
class ID ratio yeareye;
model score = ratio year ratio*year;
repeated year/ subject=id type=cs;
lsmeans ratio*year;
run;

 

Then the sgplot:

proc sgplot data=means1;
series x=year y=estimate/ group=ratio;
xaxistable n/ class=ratio location=outside colorgroup=ratio valueattrs=(weight=bold
size=10) labelattrs=(weight=bold size=10) title='Sample size at each visit'
titleattrs=(weight=bold size=10);
run;

 

Thanks,

 

 

 

Jest
Obsidian | Level 7

I was actually able to solve it by generating the sample size using proc means and then merging with the lsmeans generated from proc mixed and using sgplot...

 

But if there is any way sample sizes at each time point can be generated using proc mixed, I would appreciate knowing that for you future reference.

 

thanks,.

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
  • 9 replies
  • 1309 views
  • 0 likes
  • 3 in conversation