DATA Step, Macro, Functions and more

How to output graphics from SAS UE

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 114
Accepted Solution

How to output graphics from SAS UE

I have the attaced code which produces the desired graph:

proc sgplot data=PKALLD NOAUTOLEGEND;
  title "Fit and Confidence Band from Precomputed Data";
  band x=TIME lower=lcl5  upper=UCL5 / legendlabel="95% CLI" name="band1"; 
  
       band x=TIME lower=LCL50 upper=UCL50 /fillattrs=GraphConfidence2
       legendlabel="95% CLM" name="band2";
       
       band x=TIME lower=LCL95 upper=UCL95 /legendlabel="95% CLM" name="band3";
       SCATTER X=TIME Y=P5/ markerattrs=(symbol=Circle color=RED);
       SCATTER X=TIME Y=P50/ markerattrs=(symbol=SQUAREFILLED color=RED);
       SCATTER X=TIME Y=P95/ markerattrs=(symbol=ASTERISK color=RED);
       xaxis label='Time (hrs)';
        yaxis label='Concentration(ng/ml)';
 RUN;

A portion of the data PKALLD is attached:  Can someone tell me how to output the graph to a file?

TIMEp5P50P95LCL5LCL50LCL95UCL5UCL50UCL95
0000000000
0.2500.260261.10530.02310.1790.7210.1150.3321.02
0.50.140030.92723.32230.1290.8782.730.6031.513.85
10.839313.50028.86910.5622.555.341.744.337.65
1.51.71544.751559.26481.173.576.092.375.658.95

Accepted Solutions
Solution
‎08-22-2017 04:07 PM
Super User
Posts: 22,820

Re: How to output graphics from SAS UE

Posted in reply to jacksonan123

There's a little gear on the top right of your posts that allow you to edit it. Or you could have kept it in the same thread rather than start the discussion all over again. And I was that person in the first place, and yes, your code and text as posted were illegible. 

 

I will combine them back, because there was no reason to separate them.

 

Here's an example for PNG and PDF. I've leave the rest to you to figure out.

 

 

*specify the path to where the files should be saved;
ods listing  gpath='/folders/myfolders/';
*specify the output type;
ods graphics / imagename='mygraph' imagefmt=png;
proc sgplot data=sashelp.class;
scatter x=weight y=height;
run;quit;


*Demo for creating a PDF;
ods pdf file='/folders/myfolders/demo.pdf' style=meadows;

proc sgplot data=sashelp.class;
scatter x=weight y=height;
run;quit;

ods pdf close;

 

 

View solution in original post


All Replies
Super User
Posts: 22,820

Re: How to output graphics from SAS UE

Posted in reply to jacksonan123

Why did you start a new question? 

What kind of output do you want, PDF, JPG, PNG, RTF, PPTX, XLSX?

 

 

Frequent Contributor
Posts: 114

Re: How to output graphics from SAS UE

I started a new output since someone stated that they could not read my code
in a previous E-mail.

I would like the choice of pdf, jpg, or png.
Solution
‎08-22-2017 04:07 PM
Super User
Posts: 22,820

Re: How to output graphics from SAS UE

Posted in reply to jacksonan123

There's a little gear on the top right of your posts that allow you to edit it. Or you could have kept it in the same thread rather than start the discussion all over again. And I was that person in the first place, and yes, your code and text as posted were illegible. 

 

I will combine them back, because there was no reason to separate them.

 

Here's an example for PNG and PDF. I've leave the rest to you to figure out.

 

 

*specify the path to where the files should be saved;
ods listing  gpath='/folders/myfolders/';
*specify the output type;
ods graphics / imagename='mygraph' imagefmt=png;
proc sgplot data=sashelp.class;
scatter x=weight y=height;
run;quit;


*Demo for creating a PDF;
ods pdf file='/folders/myfolders/demo.pdf' style=meadows;

proc sgplot data=sashelp.class;
scatter x=weight y=height;
run;quit;

ods pdf close;

 

 

Frequent Contributor
Posts: 114

SGPLOT output to a file

Posted in reply to jacksonan123

I am using SAS UE and have been trying to find online how to write the graphical output to a file under myfolders with no success.

 

Can someone direct me to a post that lists the types of outputs available which can be written to a file when one uses SAS UE?

 

Thanks

Super User
Posts: 22,820

Re: SGPLOT output to a file

Posted in reply to jacksonan123
See the examples here:
http://support.sas.com/documentation/cdl/en/grstatug/69747/HTML/default/viewer.htm#n1h5mi4oze2sc7n1w...

SAS UE isn't differ AFAIK, except for the path references which are similar to using SAS on a server.
Frequent Contributor
Posts: 114

Re: SGPLOT output to a file

I searched several sites and I found the following:

Creating a graph by using the GTL involves the following steps:

1. Define the structure of the graph by using the GTL syntax in a DEFINE
STATGRAPH block in a TEMPLATE procedure statement.

2. Run the TEMPLATE procedure to compile and save the template definition.


3. Run an SGRENDER procedure statement that specifies the template and
graph data set by name in order to generate the graph.

The code that I have runs okay and gives me the desired graph but when I try
the code under template it fails and to me it appears that one needs to run
this under sgrender which I tried and it failed.

proc sgplot data=PKALLD NOAUTOLEGEND;

title "Fit and Confidence Band from Precomputed Data";

band x=TIME lower=lcl5 upper=UCL5 / legendlabel="95% CLI" name="band1";


band x=TIME lower=LCL50 upper=UCL50 /fillattrs=GraphConfidence2

legendlabel="95% CLM" name="band2";

band x=TIME lower=LCL95 upper=UCL95 /legendlabel="95% CLM"
name="band3";

SCATTER X=TIME Y=P5/ markerattrs=(symbol=Circle color=RED);

SCATTER X=TIME Y=P50/ markerattrs=(symbol=SQUAREFILLED color=RED);

SCATTER X=TIME Y=P95/ markerattrs=(symbol=ASTERISK color=RED);

xaxis label='Time (hrs)';

yaxis label='Concentration(ng/ml)';

RUN;

Can you tell me what I have done wrong which causes my code to fail under
template since I get errors stating that my axis statements are not valid or
out of proper order?

proc template;

define statgraph newfit;

begingraph;

entrytitle "Model Qualification plot";

layout overlay;

band x=TIME lower=lcl5 upper=UCL5 /

legendlabel="95% CLI" name="band1";

band x=TIME lower=LCL50 upper=UCL50 /fillattrs=GraphConfidence2

legendlabel="95% CLM" name="band2";

band x=TIME lower=LCL95 upper=UCL95 /

legendlabel="95% CLM" name="band3";

SCATTER X=TIME Y=P5/ markerattrs=(symbol=Circle color=RED);

SCATTER X=TIME Y=P50/ markerattrs=(symbol=SQUAREFILLED color=RED);

SCATTER X=TIME Y=P95/ markerattrs=(symbol=ASTERISK color=RED);

xaxis label='Time (hrs)';

yaxis label='Concentration(ng/ml)';

endlayout;

endgraph;

end;

run;

This is a small section of my data:


TIME

P5

P50

P95

LCL5

LCL50

LCL95

UCL5

UCL50

UCL95


0

0

0

0

0

0

0

0

0

0


0.25

0

0.26026

1.1053

0.0231

0.179

0.721

0.115

0.332

1.02


0.5

0.14003

0.9272

3.3223

0.129

0.878

2.73

0.603

1.51

3.85


1

0.83931

3.5002

8.8691

0.562

2.55

5.34

1.74

4.33

7.65


1.5

1.7154

4.75155

9.2648

1.17

3.57

6.09

2.37

5.65

8.95




Super User
Posts: 22,820

Re: SGPLOT output to a file

Posted in reply to jacksonan123
Format this so it's legible please. Use the insert code to insert code and use a data step so we can just run your code and get your data. You also haven't included your SGRENDER proc. If it's easier use the SASHELP datasets as your example data since everyone has access to those.
Super User
Posts: 22,820

Re: SGPLOT output to a file

Posted in reply to jacksonan123
And this seems very different from your original question. That's not a major concern but it's helpful to state that, and if your original problem is solved.
Frequent Contributor
Posts: 114

Re: SGPLOT output to a file

I still have the original question but I was merely trying to show what I
had resulted based upon the suggestion at this site


wer.htm#n1h5mi4oze2sc7n1wcxh7sc0onui.htm>
http://support.sas.com/documentation/cdl/en/grstatug/69747/HTML/default/view
er.htm#n1h5mi4oze2sc7n1wcxh7sc0onui.htm

I will repost the code and data as suggested.
☑ This topic is solved.

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

Discussion stats
  • 9 replies
  • 157 views
  • 0 likes
  • 2 in conversation