BookmarkSubscribeRSS Feed
PaigeMiller
Diamond | Level 26

Can I programatically test to see if ODS GRAPHICS has been set to on or off? If so, how?

--
Paige Miller
6 REPLIES 6
art297
Opal | Level 21

Paige,

While I would guess there is some way of checking, I haven't been able to find it.  However, multiple 'ods graphics on' statements don't appear to produce any error or warning messages, and may be desired in order to modify or add some of the options one can include.  Take a look at: http://www.wuss.org/proceedings08/08WUSS%20Proceedings/papers/how/how04.pdf

Cynthia_sas
SAS Super FREQ

Hi:

  Art is correct, multiple ODS GRAPHICS statments don't hurt anything. You can always look in the SAS Registry to see the "default state", however, I prefer to just be explicit in my code with ODS GRAPHICS ON; before my step and ODS GRAPHICS OFF; after my step. Then I don't have to worry about someone looking at my code and trying to figure out whether ODS GRAPHICS was on or off. It is evident in my program.

  If you have SAS 9.2, you always had to issue these statements to use ODS GRAPHICS with the SAS/STAT procedures. Then in 9.3, the default was for ODS GRAPHICS to be turned ON by default (but you could change that). And, as Art said, an explicit ODS GRAPHICS statement isn't going to generate a warning if it's already on and if it's off and you want it on, why worry -- just issue the statement to make sure it's on.

  cynthia

PaigeMiller
Diamond | Level 26

Saying I don't need it doesn't answer the question. I say I do need it. You could make the exact same claim about ODS LISTING being on or off, that you don't need to check it, but SAS does provide a way to check the status of ODS LISTING.

However, if there is no such method, as Art claims, that is an answer, although a disappointing one.

--
Paige Miller
Cynthia_sas
SAS Super FREQ

Hi:

  I understand your point. Clearly, you feel, strongly, that you need a way to test whether ODS GRAPHICS is ON or OFF.


  ODS GRAPHICS ON without an open destination doesn't -do- anything. Having used ODS since it was first introduced, I have just gotten used to the idea that some statements matter if they are "ON" or "OFF" -- like ODS LISTING, for example. But other statements are not as critical. For example, it does make sense (to me) to show the state of a destination or see what destinations are open in a program. But ODS GRAPHICS is a control statement. It has a default state. It is not technically a file destination. If ALL destinations are closed, an ODS GRAPHICS ON statement doesn't do anything:


301  ods _all_ close;
302  ods graphics on;
303  proc freq data=sashelp.class;
304    tables age / plots=all;
305  run;

WARNING: No output destinations active.
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE FREQ used (Total process time):
      real time           0.07 seconds
      cpu time            0.03 seconds


The warning message that you get is NOT about ODS GRAPHICS, it's about no destination being active or available for ODS GRAPHICS to use. The fix for this is not to check whether ODS GRAPHICS is ON, the fix for this is to turn a destination ON. The warning message tells you that there's no place for ODS GRAPHICS to send output. ODS GRAPHICS sends output to open destinations, either in the form of an embedded image for RTF and PDF or in the form of a PNG file for LISTING and HTML.

http://support.sas.com/documentation/cdl/en/statug/65328/HTML/default/viewer.htm#statug_odsgraph_sec...

http://support.sas.com/documentation/cdl/en/statug/65328/HTML/default/viewer.htm#statug_odsgraph_sec...


  If you want the developers to investigate or add an enhancement to ODS GRAPHICS so there is a programmatic way to detect whether ODS GRAPHICS is ON or OFF, then you can open a track with Tech Support and put in an enhancement request. Or, add this item to the Ballot for other users to vote on as being desirable. Ballot items are added to the survey based on suggestions that customers  submit to SAS throughout the year (here's the direct link to submit a ballot item: http://support.sas.com/feedback/form?http://communities.sas.com/community/support-communities/ballot). You can vote on Ballot items here: http://support.sas.com/community/ballot/ .


  I'm sure that you have a good reason for wanting to check this in a program. My only intent was to reassure you that, in the absence of a way to check the current state, it would not adversely impact anything to issue the ODS GRAPHICS ON; statement again. I understand that you are disappointed. Get your item on the SAS Ballot -- items on the ballot do get implemented, if enough users want them or agree with you that they are necessary.

cynthia


PaigeMiller
Diamond | Level 26

Yes, I understand that it doesn't make sense to you. It makes perfect sense to me, and I don't see any reason to debate this.

Apparently, it is my understanding that the next version of SAS, which has not been released to the public, has a macro variable &sysodsgraphics that allows you to check.

--
Paige Miller

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1289 views
  • 0 likes
  • 3 in conversation