BookmarkSubscribeRSS Feed
mmohotsi
Quartz | Level 8

I am trying to draw a graph whose dates are the same in a large data set. The data set attached is only a subset of a large data set. What SAS does is that it adds the Y values and plot them as one point and this distorts the results. I have used the code below to draw the corresponding plot

 

proc sgplot data=reset ;
vline Date / response=Result group=Structure groupdisplay=cluster;
xaxis interval=Auto type=time label='Sampled Date' LABELATTRS=(weight=bold size=9)
VALUEATTRS=(family=arial size=9 style=normal weight=normal );
yaxis values=(0 to 100 by 5) LABELATTRS=(weight=bold size=9)
VALUEATTRS=(family=arial size=9 style=normal weight=normal );;
refline 29 / axis=y label=('Expected Result') lineattrs=(color=red pattern=dash)
labelattrs=(size=12) labelloc=outside;
title1 j=c " design Structure" bold;
run;

 

Is there a way to avert this problem? Maybe draw a statistic like the Mean, Max of the results corresponding to the dates OR perhaps have the same dates included in the x-axis the with their distinct values?

 

3 REPLIES 3
sbxkoenk
SAS Super FREQ

It adds the Y-values (for same date) because the default STAT displayed is SUM when you have specified the RESPONSE= option.

 

Here are all the statistics  you can display:

STAT=FREQ | MEAN | MEDIAN | PERCENT | SUM

 

You can add this STAT= option after the forward slash in your vline statement.

 

BR,

Koen

sbxkoenk
SAS Super FREQ

Maybe you want a vbox instead of a vline statement?

 

Here's the 

Graphics Samples Output Gallery

Every graph comes with its code.

 

Specifically for PROC SGPLOT:

https://support.sas.com/sassamples/graphgallery/PROC_SGPLOT.html

 

BR,

Koen

Ksharp
Super User

Why are you using VLINE ? why not use SCATTER?

VLINE would get MEAN of obs which have the same date.

And you'd post a desired graph to explain what you are looking for ?

libname x  v9 'C:\Users\xiakeshan\Documents\Downloads';

data reset;
 set x.reset;
run;

proc sgplot data=reset ;
scatter x=Date y=Result/jitter group=Structure ;
xaxis interval=Auto type=time label='Sampled Date' LABELATTRS=(weight=bold size=9)
VALUEATTRS=(family=arial size=9 style=normal weight=normal );
yaxis values=(0 to 100 by 5) LABELATTRS=(weight=bold size=9)
VALUEATTRS=(family=arial size=9 style=normal weight=normal );;
refline 29 / axis=y label=('Expected Result') lineattrs=(color=red pattern=dash)
labelattrs=(size=12) labelloc=outside;
title1 j=c " design Structure" bold;
run;

Ksharp_0-1778570043635.png

 

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

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

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 152 views
  • 0 likes
  • 3 in conversation