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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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