The SAS Output Delivery System and reporting techniques

Creating a graph in one program but printing it in another

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 11
Accepted Solution

Creating a graph in one program but printing it in another

Is it possible to create a graph in one program but print/reference it in another program for ODS output to excel.  I have about 5 different programs that do certain tasks and create various tables and graphs.  I want to then export all of those to an excel file at the end.  I figured out how to loop through all the work tables and print them but I cant seem to figure out how to reference a graph created in another program.  I am hoping it is just some option I am missing in the SGPLOT procedure.  I would like to avoid creating a persistent file (like a .png file) if possible and hoping I can just reference it in memory. 

 

The reason I want to do it this way is this is going to be a process that will expand over time.  More graphs/tables may be added and I don't want to have to repeat code multiple times when we add new processes


Accepted Solutions
Solution
‎02-22-2018 03:53 PM
SAS Super FREQ
Posts: 508

Re: Creating a graph in one program but printing it in another

Posted in reply to hulksmash

The ODS DOCUMENT statement opens a document--a repository of information.  Leave it open as long as you like.  You can close it and reopen it if you like.  At the end, you close it.  The WRITE option starts a new document discarding any information that was there.  Without that option, new output is appended to the document.

 

Then, yes, use PROC DOCUMENT to display any subset of the results. You can even reorder the results.  You can change the results.  There is A LOT that you can do with PROC DOCUMENT.

 

You will typically need to run PROC DOCUMENT to list the contents of the document so that you know what paths to specify.

View solution in original post


All Replies
SAS Super FREQ
Posts: 508

Re: Creating a graph in one program but printing it in another

Posted in reply to hulksmash

Yes.  Store the results in the ODS document.  This example works just within a step, but the documentation shows you how to save the document. http://go.documentation.sas.com/?docsetId=odsug&docsetTarget=n0nz6m09jrb7jsn1h8rngbvzk65u.htm&docset...

 

ods document name=MyDoc (write);
proc reg data=sashelp.class;
   model weight=height;
quit;
ods document close;

proc document name=MyDoc;
   list / levels=all;
quit;

proc document name=MyDoc;
   replay \Reg#1\MODEL1#1\ObswiseStats#1\Weight#1\FitPlot#1;
quit;
Occasional Contributor
Posts: 11

Re: Creating a graph in one program but printing it in another

Posted in reply to WarrenKuhfeld

Looks like this may be what I am looking for.  To be clear I will need to run the "ods document name=mydoc;" before each program correct and than use the "proc document" at the end to list and ODS to excel?

Solution
‎02-22-2018 03:53 PM
SAS Super FREQ
Posts: 508

Re: Creating a graph in one program but printing it in another

Posted in reply to hulksmash

The ODS DOCUMENT statement opens a document--a repository of information.  Leave it open as long as you like.  You can close it and reopen it if you like.  At the end, you close it.  The WRITE option starts a new document discarding any information that was there.  Without that option, new output is appended to the document.

 

Then, yes, use PROC DOCUMENT to display any subset of the results. You can even reorder the results.  You can change the results.  There is A LOT that you can do with PROC DOCUMENT.

 

You will typically need to run PROC DOCUMENT to list the contents of the document so that you know what paths to specify.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 127 views
  • 1 like
  • 2 in conversation