BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
shonn2nd
Fluorite | Level 6

Hi all,

 

I am not sure what is the difference between the following codes with one having ODS GRAPHICS ON and the other without. Since I found that the results are the same:

 

First one:

 

ODS GRAPHICS ON;
PROC GLM DATA=viagra plots=all ;
CLASS dose;
MODEL libido = dose /SOLUTION ;
MEANS dose;
ESTIMATE 'linear' dose -1 0 1;
ESTIMATE 'linear' dose -1 0 1;
ESTIMATE 'placebo vs other' dose -2 1 1 /;
ESTIMATE 'low vs high' dose 0 -1 1 /;
MEANS dose /TUKEY REGWQ HOVTEST WELCH ;
RUN; QUIT;
ods graphics close;

Second one:

PROC GLM DATA=viagra plots=all;
CLASS dose;
MODEL libido = dose /SOLUTION ;
MEANS dose;
ESTIMATE 'linear' dose -1 0 1;
ESTIMATE 'linear' dose -1 0 1;
ESTIMATE 'placebo vs other' dose -2 1 1 /;
ESTIMATE 'low vs high' dose 0 -1 1 /;
MEANS dose /TUKEY REGWQ HOVTEST WELCH ;
RUN; QUIT;

Both codes produce the same plots. Then why do we need ODS GRAPHICS ON in the first code?

 

(attached is my dataset). Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Your log should show something similar to this:

332  ods graphics close;
                  -----
                  22
                  202
ERROR 22-322: Syntax error, expecting one of the following: ;, /, NO, OFF, ON, YES.

ERROR 202-322: The option or parameter is not recognized and will be ignored.


So if you ran the code in the order shown you did not actually turn ODS GRAPHICS OFF.

 

Try rerunning with Ods graphics off;

and see if you still get plots from the second proc glm call.

View solution in original post

6 REPLIES 6
ballardw
Super User

Your log should show something similar to this:

332  ods graphics close;
                  -----
                  22
                  202
ERROR 22-322: Syntax error, expecting one of the following: ;, /, NO, OFF, ON, YES.

ERROR 202-322: The option or parameter is not recognized and will be ignored.


So if you ran the code in the order shown you did not actually turn ODS GRAPHICS OFF.

 

Try rerunning with Ods graphics off;

and see if you still get plots from the second proc glm call.

shonn2nd
Fluorite | Level 6

Thank you. When I tried ods graphics off. My second code couldn't produce the graphics. But when I tried ods graphics on and ods graphics close (my first code) and executed my second code, the results still showed the graphics. Is this because ods graphics close doesn't really turn off the plotting function? If I really want to turn plotting off, I have to use ods graphics off instead.

PGStats
Opal | Level 21

You get the same graphs because ODS GRAPHICS is ON by default in recent versions of SAS. It was OFF in older versions, which is why the doc often insists you should turn it on to get the graphs.

PG
shonn2nd
Fluorite | Level 6

PG,

 

Thank you for the answer. So, do you mean by default even if I don't declare ods graphics on, the current sas version will still produce graphics or because ods graphics off don't really turn the plotting off? Thanks.

PGStats
Opal | Level 21

ODS GRAPHICS is ON unless you turn it OFF. You will want to turn it off for testing sometimes but mostly, you control which graphs are produced with the PLOTS= option in the procs.

PG
ballardw
Super User

@shonn2nd wrote:

PG,

 

Thank you for the answer. So, do you mean by default even if I don't declare ods graphics on, the current sas version will still produce graphics or because ods graphics off don't really turn the plotting off? Thanks.


The syntax allows using either OFF or NO. Close is an error so the statement does not do anything except generate error messages in the log.

Once you turn ODS Graphics on in a session it will remain in effect until you actually submit an Ods Graphics off; (or no) to stop it.

So whether they are generated or not is under your control if you use the correct syntax.

 

If you have preferences to Save settings on exit (Tools>Options>Preferences>General tab check box) you might have the option in effect the next time you start SAS. I haven't tested this and may change by SAS operating environment.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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

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
  • 6 replies
  • 1035 views
  • 4 likes
  • 3 in conversation