BookmarkSubscribeRSS Feed
freshap
Fluorite | Level 6

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 : 

sas1.PNG

 

The thing is if I run a second time the exact same code (by clicking the "Refresh" button), here is what I would get : 

 

sas2.PNG

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

8 REPLIES 8
Kurt_Bremser
Super User

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.

Kurt_Bremser
Super User

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;
ChrisHemedinger
Community Manager

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;
SAS Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.
freshap
Fluorite | Level 6

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 !

Kurt_Bremser
Super User

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.

freshap
Fluorite | Level 6

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. 

ChrisHemedinger
Community Manager

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.

SAS Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.
ballardw
Super User

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

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 710 views
  • 2 likes
  • 4 in conversation