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

I'm trying to move from PC Base SAS to SAS Enterprise Guide (EG), but I've found some code works in Base SAS, but not in SAS EG.

Here's an example. In Base SAS, when I close my ODS PDF and turn ODS HTML back on, I have these 2 statements:

ods pdf close;
ods html;

This has always worked in Base SAS. But it fails in Enterprise Guide with this error:

ERROR: Insufficient authorization to access C:\WINDOWS\system32\sashtml1.htm.
ERROR: No body file. HTML output will not be created.

Base SAS is correctly setting default HTML output to my temporary WORK library, which I am authorized to write to, but Enterprise Guide is defaulting HTML output (in this case) to the C:\WINDOWS\system32 folder that I am NOT authorized to write to.

Huh? Why? And how to remedy this without re-writing all my SAS code?

 

If it helps, I'm using Base SAS 9.4 TS Level 1M7, and Enterprise Guide 8.3.0.103.

1 ACCEPTED SOLUTION

Accepted Solutions
bnawrocki
Quartz | Level 8

I've been writing code in Base SAS like this for years, and seemed to do what I wanted - to send the results of the 2nd PROC PRINT to a PDF, and send results for the 1st and 3rd PROC PRINTs to the Results screen within SAS (not to an external HTML file):

proc print data=sashelp.cars(obs=1); run;
ods html close;
ods pdf file='c:\temp\temp.pdf';
proc print data=sashelp.cars(obs=2); run;
ods pdf close;
ods html;
proc print data=sashelp.cars(obs=3); run;

But when I test this within SAS EG, the "ods html close" statement seems to have no effect - the 2nd PROC PRINT is also written to the Results screen within SAS EG.

 

So, my solution will be to remove the "ods html close" statement, which means I don't need an "ods html" statement, so the error in SAS EG for the "ods html" statement will be averted.

View solution in original post

12 REPLIES 12
ChrisNZ
Tourmaline | Level 20

That's a big fail by your SAS admin, who needs to change the server's default path.

The default directory of your SAS session should be for example your WORK directory.

It's also a small fail from SAS (who do not have this setting as default) and maybe from you (do you just save files into any random location rather than coding the path?)

bnawrocki
Quartz | Level 8

I should have made it clear - Base SAS and SAS EG are both running standalone on my local PC. We don't have a SAS server, so although I'd like to blame my SAS admin, that person doesn't exist.

Kurt_Bremser
Super User

@bnawrocki wrote:

I should have made it clear - Base SAS and SAS EG are both running standalone on my local PC. We don't have a SAS server, so although I'd like to blame my SAS admin, that person doesn't exist.


Oh, it does. It's you.

As soon as you install software on your computer, you become the admin for it. And SAS is way bigger and more complex than anything else you ever installed (my guess).

(MS Flight Simulator might need more disk space, but most of that is just scenery data)

ballardw
Super User

Proximate cause of the error in EG is that the path likely is the path on the SERVER running EG and you do not have any permissions.

If you think you are writing to your computer, as in the past, that is a big change when moving to EG. You need to talk  to your SAS Admin about permissions and where you can/should write files. The Admin might help you set up a share to allow writing to your computer that depends on your organization.

Kurt_Bremser
Super User

Make it a habit to always use fully qualified path names for anything you create, which includes the files created by ODS.

EG will create HTML output automatically if you instruct it to do so, and it will create the files in your WORK and download them to your PC for viewing.

bnawrocki
Quartz | Level 8

I don't have a SAS server -- everything's on my PC.

I don't think I should have to change my SAS code and specify a directory for the HTML output to go. So this SAS statement works differently in Base 9.4 SAS and SAS EG? I've been running this code in Base SAS without any issues for years:

ods html;

I only write that line after I've closed the ods html output with this statement, along with opening up, say, an ODS output to a PDF, and then later want to reset output to html --

ods html close;
ods pdf file=.....;

I suppose one option is to NEVER close HTML output. Is there another option? If SAS EG is requiring the ODS HTML statement to specify the work library directory, is there a macro or system option or function I could point to rather than writing the entire path each time like the following. This won't work if multiple people run this SAS EG code because it has my name in the path:

ods html "C:\Users\BruceNawrocki\AppData\Local\Temp\SAS Temporary Files....";
Kurt_Bremser
Super User

Go to Tools - Options - Results and select HTML. EG adds the ODS statements on its own so it can then load the resulting file.

TBH, I didn't even know that ODS HTML would work without a filename, and I'd never let the software decide on its own where to put data. Too much room for accidents there, as you experience right now. The way your SAS is set up it starts the workspace server session from the system32 directory, where non-admin users do not have write permission.

And if you don't like EG's internal mechanism designed for the pointy-clickers, go the whole way, take control and use an explicit location in your code.

ChrisNZ
Tourmaline | Level 20

> I don't think I should have to change my SAS code and specify a directory for the HTML output to go.

Well we disagree. You should decide where your files go.

 

> So this SAS statement works differently in Base 9.4 SAS and SAS EG?

They have different configuration files, so yes.

You can see that by running  proc options; run;

Look for entry -SASINITIALFOLDER in the config file and modify as you see fit.

Patrick
Opal | Level 21

SAS EG is the client. It still uses the same SAS "server" to execute the code - but the path is now different.

Unlike in your existing code you should always define a path in the code but... to make your current code work add the following to EG to define a default path that points to your current Work directory.

Patrick_0-1634096964092.png

%let rc = %sysfunc(dlgcdir("%sysfunc(pathname(work))"));

Here some reading for you:

https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/graphref/n014ro62pa3xu0n165t2qpffbmiv.htm

https://blogs.sas.com/content/sgf/2018/05/18/how-to-change-your-working-directory-for-sas-with-the-d...

https://blogs.sas.com/content/sasdummy/2018/08/28/sas-current-directory/ 

 

 

ChrisNZ
Tourmaline | Level 20

Nice. A useful function I didn't know. Unavailable in M2. 😞

Kurt_Bremser
Super User

@bnawrocki wrote:

...

I don't think I should have to change my SAS code and specify a directory for the HTML output to go.


There is Maxim #43 of the Maxims of Maximally Effective Mercenaries from schlockmercenary.com (from where I got the inspiration for my Maxims). It goes

"If it is stupid and it works, it's still stupid, and you're lucky"

Up to now, you were lucky.

Also see my Maxim 31: Computers Are Dumb. They need your adult oversight.

Granted that back then you did not know better than to let chance decide where files should go, but now you know, and so you have to correct it.

bnawrocki
Quartz | Level 8

I've been writing code in Base SAS like this for years, and seemed to do what I wanted - to send the results of the 2nd PROC PRINT to a PDF, and send results for the 1st and 3rd PROC PRINTs to the Results screen within SAS (not to an external HTML file):

proc print data=sashelp.cars(obs=1); run;
ods html close;
ods pdf file='c:\temp\temp.pdf';
proc print data=sashelp.cars(obs=2); run;
ods pdf close;
ods html;
proc print data=sashelp.cars(obs=3); run;

But when I test this within SAS EG, the "ods html close" statement seems to have no effect - the 2nd PROC PRINT is also written to the Results screen within SAS EG.

 

So, my solution will be to remove the "ods html close" statement, which means I don't need an "ods html" statement, so the error in SAS EG for the "ods html" statement will be averted.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 12 replies
  • 5896 views
  • 5 likes
  • 5 in conversation