BookmarkSubscribeRSS Feed
Tpham
Quartz | Level 8

So my code seem to work, but it doesn't seem to save my graph as an image file in the directory I specified. I am unsure how to troubleshoot this and was wondering if anyone can give me some suggestions.

So when I goto C:\Graphs, there is nothing there. Does ODS Graphics not work with Proc Gchart? I used the exact ODS graphics and ODS listing code with Proc SGpanel and it works

%macro graph (var);

DATA _null_;

  SET fich;

  array vars(*) &var;

  DO i=1 TO dim(vars);

  call symput("mvNAME"||strip(i),strip(vname(vars(i))));

  call symput("mvLAB"||strip(i),strip(vlabel(vars(i))));

  END;

  call symput("mvNB",strip(dim(vars)));

RUN;

%DO b=1 %TO &mvNB;

Title "&&mvLAB&b";

ods graphics on/reset=all imagename="&&mvNAME&b" width=27.8cm height=14cm;

ods listing style=custom2 gpath="c:\Graphs";

proc gchart data=fich;

  pie &&mvNAME&b /     DISCRETE VALUE=OUTSIDE

                 PERCENT=OUTSIDE SLICE=OUTSIDE;

  run; quit;

ods graphics off;

%end;

%mend graph;

%graph(CS1-CS6);

7 REPLIES 7
Reeza
Super User

GChart does not use ODS, the SG procedures do.

I'm not sure how to save your graphics either Smiley Sad

Tpham
Quartz | Level 8

Ah that is why. I have to see if I can create a pie chart with SG procedures.

ballardw
Super User

If you send your HTML output to a specific folder and use the NAME option you will get a PNG file with desired name:

ods html path="C:\graphs";

proc gchart data=fich;

  pie &&mvNAME&b /     DISCRETE VALUE=OUTSIDE

                 PERCENT=OUTSIDE SLICE=OUTSIDE name=&&mvNAME&b;

  run; quit;

You should be able to make all of your graphs with one pass through the data:

proc gchart data=fich;

%DO b=1 %TO &mvNB;

  pie &&mvNAME&b /     DISCRETE VALUE=OUTSIDE

                 PERCENT=OUTSIDE SLICE=OUTSIDE name=&&mvNAME&b;

  run;

%end;

quit;

though that won't address your potential TITLE issue.

Tpham
Quartz | Level 8

The title in the graph would be nice, but not essential... Ssince I will be copying and pasting all of these pie chart (82 of them) into an online survey.. I am hoping to have the title in the image itself just as another Quality check to make sure it's the right one.

I'll try this tomorrow and report back if it works.

Reeza
Super User

Why not output to ODS RTF then?

Reeza
Super User

If you're on SAS 9.4 you can use SGTemplate/Render:

SAS(R) 9.4 Graph Template Language: Reference, Fourth Edition

Tpham
Quartz | Level 8

Thanks sadly on 9.2

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 2222 views
  • 6 likes
  • 3 in conversation