I am trying to run a macro to create multiple pie charts for several image numberse (1-34). Below is my code and log. I don't get any errors in my log, but I don't get any output either (no plots are generated in results viewer or ods rtf). Please help!
ods graphics /reset=all width=2in height=2in;
%macro pie;
%do num=1 %to 34;
proc sgpie data=data noautolegend
dattrmap=attrmap;
pie feature /
datalabelloc=inside datalabeldisplay=(response percent ) datalabelattrs=(size=11 family='CENTB' weight=bold)
startangle=90 dataskin=crisp attrid=myid;
where ImageID=#
run;
%end;
%mend pie;
%pie;
Log:
NOTE: PROCEDURE SGPIE used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Do you get any WARNINGs in the log?
Can you please show us the ENTIRE* log for this macro (including the part where you issue the ODS RTF command)? (And please do this every time in the future, show us the ENTIRE log for this macro, do not show us a small portion of the log). Please copy the log as text and paste it into the window that appears when you click on the </> icon.
* — as this log is iterative, and runs essentially the same code for 34 iterations, just show us the log for the first five iterations
10150 ods rtf file="C:\Users\abi\Desktop\Output\macrotest &today..rtf" 10151 startpage=no bodytitle; NOTE: Writing RTF Body file: C:\Users\abi\Desktop\Output\macrotest 050622.rtf 10152 ods graphics on; 10153 10154 10155 ods graphics /reset=all width=2in height=2in; 10156 %macro pie; 10157 %do num=1 %to 34; 10158 proc sgpie data=data noautolegend 10159 dattrmap=attrmap; 10160 pie feature / 10161 datalabelloc=inside datalabeldisplay=(response percent ) datalabelattrs=(size=11 family='CENTB' weight=bold) 10162 startangle=90 dataskin=crisp attrid=myid; 10163 where ImageID=# 10164 run; 10165 %end; 10166 %mend pie; 10167 %pie; NOTE: PROCEDURE SGPIE used (Total process time): real time 0.00 seconds cpu time 0.00 seconds NOTE: PROCEDURE SGPIE used (Total process time): real time 0.00 seconds cpu time 0.00 seconds NOTE: PROCEDURE SGPIE used (Total process time): real time 0.00 seconds cpu time 0.00 seconds NOTE: PROCEDURE SGPIE used (Total process time): real time 0.00 seconds cpu time 0.00 seconds NOTE: PROCEDURE SGPIE used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 10168 10169 ods rtf close;
Those times showing 0.0 seconds are suspicious.
Could you turn on options MPRINT and then show the log.
Its it possible there are no records with ImageID=1,2,3 ...
It's kind of scary to see a dataset named data. But I guess it's allowed.
If you just run:
data want;
set data;
run;
Does that work? I'm wondering if maybe your code had an earlier error and it entered syntaxcheck mode and set OBS=0. That stops any code from executing.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.