Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Graphics
- /
- getting values on a gplot

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 09-29-2017 05:17 PM
(1694 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

thank you Reeza.

Is there an example code for the sgplot?

Many thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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,

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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,.

Are you ready for the spotlight? We're accepting content ideas for **SAS Innovate 2025** to be held May 6-9 in Orlando, FL. The call is **open **until September 25. Read more here about **why** you should contribute and **what is in it** for you!

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.