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?
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:
You can add this STAT= option after the forward slash in your vline statement.
BR,
Koen
Maybe you want a vbox instead of a vline statement?
Here's the
Every graph comes with its code.
Specifically for PROC SGPLOT:
https://support.sas.com/sassamples/graphgallery/PROC_SGPLOT.html
BR,
Koen
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;
Dive into keynotes, announcements and breakthroughs on demand.
Explore Now →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.