Hello,
I recently faced a problem which seems to be related with SAS parameters/options.
Let's say I have this dataset :
data toplot;
input id $ var time;
datalines;
id1 0.1 1
id2 0.2 1
id3 0.7 1
id1 1.5 2
id2 1.1 2
id3 2.1 2
;
run;
I want a graphic like this, which I plotted using the built-in functionnalities :
The thing is if I run a second time the exact same code (by clicking the "Refresh" button), here is what I would get :
I plotted these to illustrate my problem : now, any graphic I will plot won't be able to plot numbers between integers. We can see that 0.7 got truncated to 0, 1.5 to 1... any real number x will be truncated to the lowest integer n s.t. n<=x.
So basically, during my entire SAS Session, the only nice plot I will have will be the first to be plotted, and any other graphics I want will be bugged.
It really bothers me. The only thing I could think of that could cause this bug is this line of code I wrote :
OPTIONS maxmemquery=6MB;
I tried to switch it to 1GB but still didn't work, and without this line I can't plot any graphic.
Do you know any solution to my problem ?
Thanks in advance
Just tested it, the option has no effect on the graph, and the graph comes out the same when I run the code repeatedly.
#1 suspect here is that something changes your data. Work through all the code you run while doing this.
PS this is the complete code I used for testing, most of it created by the EG wizard for multiple line plots (hence the ugly code formatting):
data toplot;
input id $ var time;
datalines;
id1 0.1 1
id2 0.2 1
id3 0.7 1
id1 1.5 2
id2 1.1 2
id3 2.1 2
;
PROC SORT DATA=WORK.TOPLOT;
BY time;
RUN;
SYMBOL1
INTERPOL=JOIN
HEIGHT=10pt
VALUE=NONE
LINE=1
WIDTH=2
CV = _STYLE_
;
SYMBOL2
INTERPOL=JOIN
HEIGHT=10pt
VALUE=NONE
LINE=1
WIDTH=2
CV = _STYLE_
;
SYMBOL3
INTERPOL=JOIN
HEIGHT=10pt
VALUE=NONE
LINE=1
WIDTH=2
CV = _STYLE_
;
Legend1
FRAME
;
Axis1
STYLE=1
WIDTH=1
MINOR=NONE
;
Axis2
STYLE=1
WIDTH=1
MINOR=NONE
;
PROC GPLOT DATA = WORK.toplot;
PLOT var * time =id
/
VAXIS=AXIS1
HAXIS=AXIS2
FRAME LEGEND=LEGEND1
;
RUN;
GOPTIONS RESET = SYMBOL;
I agree with @Kurt_Bremser -- something else must be changing between runs. As you're already writing your own code, PROC SGPLOT (maybe you're already using) provides the most flexibility here. This code replicates your first plot, I think.
data toplot;
input id $ var time;
datalines;
id1 0.1 1
id2 0.2 1
id3 0.7 1
id1 1.5 2
id2 1.1 2
id3 2.1 2
;
run;
proc sgplot data=toplot;
series x=time y=var / group=id;
xaxis integer;
run;
I tried to create a new project, add a program with only both of your codes.
@Kurt_Bremser's code gives the right plot, but if I run it twice or try to plot any other plot after the problem I described will remain.
However @ChrisHemedinger's code will always work.
I used the exact same methodology and by the way, I am a 100% sure that I don't modify the data between two runs of the gplot or sgplot.
Hence I think the problem comes from the GPLOT function... but why ?
Anyway thanks for your answers, but I'm still curious as to why GPLOT does that !
Look in the settings of EG for code to be sent before/after each execution of a task or code node. There might be a setting of SAS/GRAPH options hidden in there.
You are right ✔️
In the Parameters, in the Graphical tab, I had Graphic format set to ActiveX. After trying all the options out, I found out ActiveX and Java would have this bug but any other format (Jpeg, png, gif, SAS EMF and even ActiveX Image and Java Image!) would work.
Hence, I've set this option to ActiveX Image and now everything works fine, even though I am not sure as to which format is better.
ActiveX - creates a script that is embedded in your ODS HTML that triggers the dynamic SAS/GRAPH ActiveX control to render your image in the browser. You can then "control" the image with menu options in the browser as you view it. State-of-the-art in 1998, but these days it's not so common.
ActiveXImg - this uses the SAS/Graph ActiveX control (on Windows only) to render a static version of the image.
I recommend PNG for better portable delivery (Windows and Linux). Or SVG if you want scalable plots. However, the Graph tasks in EG will use PROC GPLOT/GCHART and not the more modern SGPLOT (ODS graphics). If you're going to be doing a lot of this, it's worth learning the syntax. Simple things are simple, and complex plots are possible with more study.
What is the format you have assigned to your floating point variable? You have have assigned a format that does not display decimals such as a 4.0 then that could be the cause.
You would have to change the format for the plotting procedure (if this the cause you may have other issues with reports as well using the formatted value for somethings).
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.