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

Hi all,  I'm trying to learn base SAS, so forgive the simple questions.

 

I use the following code, following the instructions from SAS Programming 1 Essentials, Lesson 5, Practice 1, Level 2.  Here's the code:

 

I confirm the library is correct and it does generate results, but I cannot figure out why I keep getting this error:

 

 ERROR: Unable to establish ODS Graphics context.

 

It doesn't want to set up a graph.  Is this something it doesn't support? Note I do have the beginning line "ods graphics on;" and per the learning that's supposed to let me make graphs.  Is that not in OnDemand? Is there another setting in OnDemand I need to flag/remove to get this to behave? 

ods graphics on;
title "Selected Park Types by Region";
proc freq data=pg1.np_codelookup order=freq;
tables Type*Region / nocol crosslist
plots=freqplot (groupby=row scale=grouppercent orient=horizontal);
where Type in ("National Historic Site", "National Monument", "National Park");
run;
title;

Screenshot attached so you don't have to hunt through everything...I think I have it right.  What am I missing?

Thanks,

 

Ryan C

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26
Hi: In order to provide concrete assistance, we'd need to see the log of the original code that generated the error and the original log. However, this article https://sas.service-now.com/csm/en/using-the-sas-sg-procedures-or-ods-graphics-with-the-user-system-... indicates that some combination of options could cause the error and so it seems likely that when you started over in a fresh session, you may have reset any options that any of your code changed. If it happens again, your best resource would be to capture the full log and either post that or optionally (and possibly more productive in the long run) open a case with Tech Support.
Cynthia

View solution in original post

6 REPLIES 6
ryanc1979
Fluorite | Level 6

Looking at the solution, I think this trip up here was that I used "title" and not "title1". Someone confirm if that was the issue.  Thanks!

ballardw
Super User

Best would be to show the LOG. Copy the code and all of the other messages from the log. Suggest starting a new session and only running the code to assign the library/data set and the steps you show. If you get the same results then show that log. The new session means there will be less stuff to wade through that might be involved.

 

That sort of error is a bit odd and may relate to something else you had done earlier, possibly related to which ODS destination(s) are open.

 

Your question about the Title statement I would say is not likely to be the issue. The use of Title as the same as Title1 goes back about 40 years so I doubt very strongly that it has any effect. 

Kurt_Bremser
Super User
Same advice: run only the example code in a completely new session.

Researching the message found me some mentions of the USER option being set, which seems to interfere with the graphics system.
ryanc1979
Fluorite | Level 6

Hi both,

 

So doing as instructed, the new session doesn't care about "title" vs "title1", so that doesn't look like its the problem as you suggested; it runs fine now.  does SAS OnDemand for Academics have some setting with ODS?  I don't have a "user" option (at least, in this point of the Base SAS learnings I haven't found any reference to it, so I haven't come across it).  I understand it exists, I researched and saw the same thing in the documentation, I just don't know why that error flagged yesterday, and now today it's working just fine.  

I'm extremely confused.  Is this a "quirk" of SAS?

As requested, code from today and log file:

ods graphics on;
title "Selected Park Types by Region";
proc freq data=pg1.np_codelookup order=freq;
tables Type*Region / nocol crosslist
	plots=freqplot (groupby=row scale=grouppercent orient=horizontal);
where Type in ("National Historic Site", "National Monument", "National Park");
run;
title;
 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 NOTE: ODS statements in the SAS Studio environment may disable some output features.
 73         
 74         ods graphics on;
 75         title "Selected Park Types by Region";
 76         proc freq data=pg1.np_codelookup order=freq;
 77         tables Type*Region / nocol crosslist
 78         plots=freqplot (groupby=row scale=grouppercent orient=horizontal);
 79         where Type in ("National Historic Site", "National Monument", "National Park");
 80         run;
 
 NOTE: There were 204 observations read from the data set PG1.NP_CODELOOKUP.
       WHERE Type in ('National Historic Site', 'National Monument', 'National Park');
 NOTE: PROCEDURE FREQ used (Total process time):
       real time           0.42 seconds
       user cpu time       0.17 seconds
       system cpu time     0.02 seconds
       memory              26144.65k
       OS Memory           52916.00k
       Timestamp           11/14/2025 03:35:35 PM
       Step Count                        47  Switch Count  4
       Page Faults                       0
       Page Reclaims                     6898
       Page Swaps                        0
       Voluntary Context Switches        443
       Involuntary Context Switches      9
       Block Input Operations            0
       Block Output Operations           1632
       
 
 81         title;
 82         
 83         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 95         
Cynthia_sas
Diamond | Level 26
Hi: In order to provide concrete assistance, we'd need to see the log of the original code that generated the error and the original log. However, this article https://sas.service-now.com/csm/en/using-the-sas-sg-procedures-or-ods-graphics-with-the-user-system-... indicates that some combination of options could cause the error and so it seems likely that when you started over in a fresh session, you may have reset any options that any of your code changed. If it happens again, your best resource would be to capture the full log and either post that or optionally (and possibly more productive in the long run) open a case with Tech Support.
Cynthia
ryanc1979
Fluorite | Level 6
Sounds good. I'll just assume I wrote something previous to the existing exercise that was causing SAS OnDemand to get wonky. Thanks for the help everyone.

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1782 views
  • 0 likes
  • 4 in conversation