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
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
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):
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
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.
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
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
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,
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.
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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.