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

Hi,

 

I have some code that I am trying to migrate from running in enterprise guide to running in SAS studio.

 

One of the programs contains code that closes all open ODS destinations and creates a temp filename to output a pdf.

similar to the code below.

 

ods _all_ close; 
filename pdfrprt temp;
ods pdf file=pdfrprt style=sasweb;
proc print data=sashelp.class;
run;
ods pdf close;

In EG this results in a pdf file being included in the output but in SAS studio it just disappears and I can't seem to find where to view the pdf.

I don't really want to save this to a permanent location as these reports are usually just looked at once and discarded or maybe printed and the pdf output is useful for the formatting.

Obviously the programs I am migrating are more complicated than this one and do some more specific work controlling the output but this was the simplest example I could make to show the issue.

 

If anyone has a solution to control temporary ods output coming into sas studio it would be much appreciated.

 

Thanks.

 

Tim

 

1 ACCEPTED SOLUTION

Accepted Solutions
CaseySmith
SAS Employee

That is correct.  SAS Studio does not currently open ODS results generated by hand-written ODS statements in your code.  We hope to support this in the future.  For now, if you create hand-written ODS results, you'll have to navigate to the location you created the ODS results file and explicitly open it.

 

Casey


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

View solution in original post

9 REPLIES 9
Cynthia_sas
SAS Super FREQ

Hi:

  My guess is that the "working" directory folder on the server is differently set than it is in Enterprise Guide. When I use your technique in my local copy of SAS, I have an issue because the created file is given just a number, stored in my working folder and there is no file extension on the file, as shown below (when I ran your code):

working_directory.png

 

You can see that Adobe opened a file with the name #LN00010 but the file did not have a file extension, so I had to go thru the whole "open with" process on Windows.

 

  I don't know where your working directory is on your server, or if you have write access to that location. That is a question for Tech Support. You might have to try something like this:

filename pdfrprt "%sysfunc(pathname(work))";
ods pdf file=pdfrprt style=sasweb;
proc print data=sashelp.class;
run;
ods pdf close;

 

or this:

filename pdfrprt "%sysfunc(pathname(work))/pdftmp.pdf";
ods pdf file=pdfrprt style=sasweb;
** ... more code ...;
ods pdf close;

 

in SAS Studio. Personally, I've stopped using ods _all_ close; with SAS Studio. It gets a little cranky if you close all the open ODS destinations. As a best practice, I also always use a filename and file extension instead of taking a default name. With a filename and file extension, I can use operating system utilities to search for the file in order to download it.

 

Hope this helps. Otherwise, you might want to work with Tech Support on this question.

 

Cynthia

AmyP_sas
SAS Employee

Cynthia knows WAY more than I do about ODS so I'll defer to her and the other ODS experts on what to do.  But I did want to make sure you knew that we have a section in the SAS Studio User's Guide specifically on handling ODS destinations since, as Cynthia mentions, it's a bit tricky.  There may be something in there that might help.

TimCampbell
Quartz | Level 8

Thanks both,

 

It looks like my answer is that there isn't a way to get the ODS to show up in SAS Studio unless it is using the pre-defined html5 etc. so i'll just avoid ods _all_ close for now.

 

Tim

CaseySmith
SAS Employee

That is correct.  SAS Studio does not currently open ODS results generated by hand-written ODS statements in your code.  We hope to support this in the future.  For now, if you create hand-written ODS results, you'll have to navigate to the location you created the ODS results file and explicitly open it.

 

Casey


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

db_at_ccf
Fluorite | Level 6

SAS really needs to allow for SAS code to direct the SAS Studio HTML output to save via some path. This is unacceptable, especially for those of us who write macros.

Cynthia_sas
SAS Super FREQ
Hi:
I never have a problem with SAS Studio when I'm working on either the SAS OnDemand server or the SAS University Edition Virtual Machine. I either write to WORK (using the %SYSFUNC method shown in the post from 2019) or I make myself a folder under my top Studio folder called output. Then I right click on the output folder and choose Properties and find the correct path location. After that, even with my macro coding, I always have a correct filepath where I can direct my HTML, HTML5, RTF, PDF and EXCEL output. If you are having issues with a particular type of file creation and your Macro code, it would probably be better to open a new track with some code examples instead of adding onto an already solved older track.

Cynthia
db_at_ccf
Fluorite | Level 6

Cynthia,

Working with Andrew DW from SAS, I was able to put together a solution that worked within our server-based SAS Studio environment (due to HIPAA). I'll share it here. 

 

Here’s what worked, embedded in a macro to save the entire HTML output generated from the macro call. Make sure that the file or directory location in the path already exists. Here, V is a variable used in the procedures while FLDR is the destination directory. Having only the ODS HTML output type open may help to prevent problems mentioned in earlier comments. 

 

%MACRO XBETA (V, FLDR);

filename odsout "/home/…//SASStudioDirect/&FLDR";

ods _all_ close;

ods html path=odsout file="&V..html";

 

*lots of code*;

 

ods html close;

%MEND;

%XBETA(V=..., FLDR=...);

 

This code also worked when running a batch job in Linux.

 

Thanks.

Cynthia_sas
SAS Super FREQ
Hi:
Yes, having an explicit folder so you can direct output there is perfect!. I'm glad you got it worked out.
Cynthia
db_at_ccf
Fluorite | Level 6

One more thing... you can add this before the ODS HTML CLOSE; statement.

proc printto log="/home/.../&FLDR/logfile.log";
run;

 

This will shunt the log file to the same directory. 

 

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!

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
  • 9 replies
  • 4819 views
  • 3 likes
  • 5 in conversation