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

Hello all,

 

I was trying to output my graph as a PNG file, but nothing came out under my directory. Following is my code: 

filename grafout 'E:\test.png';
goptions reset=all gsfname=grafout gsfmode=replace device=png;
proc sgplot data=plot;
   vbox value / category=time group=TreatName ;
run;
quit;
filename grafout clear;

Anyone has any idea about output the graph? Thank you very much!

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Do it this way:

 

ods listing gpath='E:\';
ods graphics / imagename="test" imagefmt=png;
proc sgplot data=plot;
   vbox value / category=time group=TreatName ;
run;

View solution in original post

17 REPLIES 17
DanH_sas
SAS Super FREQ

Do it this way:

 

ods listing gpath='E:\';
ods graphics / imagename="test" imagefmt=png;
proc sgplot data=plot;
   vbox value / category=time group=TreatName ;
run;
DanH_sas
SAS Super FREQ

GOPTIONS do not apply when using the SG procedures. Use the ODS GRAPHICS statement for global options.

 

Hope this helps!

Dan

hua
Obsidian | Level 7 hua
Obsidian | Level 7
ODS GRAPHICS works well! Thanks for your help! I could get the output now!
hua
Obsidian | Level 7 hua
Obsidian | Level 7
By the way, do you know how to end this ODS GRAPHICS? Also, do you know how to set the ticks inside? Since it's showed that "TICKSTYLE=INSIDE " could only be applied in SAS 9.4M5 version or later. Mine is SAS 9.4M2.
DanH_sas
SAS Super FREQ

ODS GRAPHICS is not an ODS destination statement, like HTML or PDF. It does not have to be closed.

 

ODS GRAPHICS can be turned on and off (e.g. ods graphics off;); but the on/off does not affect the SG procedures. The on/off for controlling ODS Graphics output from SAS/STAT and other procedures that support that output.

 

As you said, the TICKSTYLE option was added after 9.4m2; however, it is definitely possible to annotate the tick marks on the inside. Here is a reference to a paper I wrote about annotation that should help you get started if you have not used annotation in this system.

 

Now You Can Annotate Your Statistical Graphics Procedure Graphs

 

Hope this helps!

Dan

benhaz
Calcite | Level 5

Hi,

Using this code , while running more than one time in a session it is creating with different file name. is there any way we can replace the existing file while running more than one time?  I am running the below code; and result is attached. Please help.

 


filename grafout '/sasdata/picture.png';
goptions reset=all
gsfname=grafout
gsfmode=replace
;

ods listing gpath='/sasdata/';
ods graphics / imagename="picture" imagefmt=png;
PROC SGPLOT DATA = OVRDATA7;
SERIES X = EXTRACT_DT Y = Overcnt;
SERIES X = EXTRACT_DT Y = UBL3Sig;
SERIES X = EXTRACT_DT Y = LBL3Sig;
TITLE 'Override Graph';
RUN;
quit;

DanH_sas
SAS Super FREQ

Yes, just add a RESET or RESET=INDEX after the / on the ODS GRAPHICS statement. If you use RESET, make sure it is the *first* option after the slash. Otherwise, you might reset other option on your statement.

 

ods graphics / reset imagename="picture" imagefmt=png;

 

Hope this helps!

Dan

benhaz
Calcite | Level 5

Thank you so much Dan. Now it is working perfectly. Appreciate your help. 

benhaz
Calcite | Level 5

Thank You so much Dan. Now it is working fine. Appreciate your help. 

SanjayAhir
Obsidian | Level 7

Hi,

 

I have used below code to create PNG graph but I am not getting title and footnote in outside the graph. I have used nogtitle option but its not working.

DanH_sas
SAS Super FREQ

What ODS destination are you using?

SanjayAhir
Obsidian | Level 7
I am using

Ods listing gpath = '';
Ods graphics ;

DanH_sas
SAS Super FREQ

NOGTITLE / NOGFOOTNOTE does not work for ODS LISTING for graphical output, as all you get is an image with no container (such as an HTML page). Are you just trying to suppress the titles?

DanH_sas
SAS Super FREQ

NOGTITLE / NOGFOOTNOTE does not work for ODS LISTING for graphical output, as all you get is an image with no container (such as an HTML page). Are you just trying to suppress the titles?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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