Data visualization with SAS programming

getting values on a gplot

Reply
Contributor
Posts: 37

getting values on a gplot

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; 

Super User
Posts: 11,121

Re: getting values on a gplot

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.

 

 

Contributor
Posts: 37

Re: getting values on a gplot

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;

Super User
Posts: 19,105

Re: getting values on a gplot

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

Contributor
Posts: 37

Re: getting values on a gplot

thank you Reeza.

 

Is there an example code for the sgplot?

 

Many thanks!

Contributor
Posts: 37

Re: getting values on a gplot

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?

 

 

Super User
Posts: 19,105

Re: getting values on a gplot

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. 

Contributor
Posts: 37

Re: getting values on a gplot

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,

 

 

 

Highlighted
Contributor
Posts: 37

Re: getting values on a gplot

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

Ask a Question
Discussion stats
  • 9 replies
  • 142 views
  • 0 likes
  • 3 in conversation