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

I'm using sgplot to produce some figures.  Sometimes the input data is empty so sgplot won't produce an output figure.  However, I want to use the output figure to proc report.  If no figure is produced, the proc report will use previous sgplot figure.  This is not I wanted.

 

How can you output an empty figure so my proc report won't use previous figures.

 

Thanks for the help

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
You can make a MACRO:


%let dsid=%sysfunc(open(input));
%let nobs=%sysfunc(attrn(&dsid,nlobs));
%let dsid=%sysfunc(close(&dsid));

%if &nobs ne 0 %then %do;
  ods graphics / reset=INDEX height=5in width=6in imagefmt=png imagename="F" border=off;
  proc sgplot data=input ...........................
%end;
%else %do;
  proc sgplot data=DUMMY..............
%end;

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

However, I want to use the output figure to proc report

 

More information is needed. Do you mean "However, I want to use the output figure in proc report"? If so, how are you doing this? Show us the parts of your code that are relevant to using an output figure in PROC REPORT.

--
Paige Miller
mmzz
Calcite | Level 5

ods listing gpath='location' ;  * store sgplot output in a folder

ods graphics / reset height=5in width=6in imagefmt=png imagename="F" border=off;

proc sgplot data=input          * sometimes input is empty

ods listing close;

 

data image;

image="location\F1.png";         * BTW why I delcated my figure name as F, but the output name is F1?

run;                                           * This is where the problem occurs, if no figure output from sgplot.  it will take an old F1.png

quit;

 

proc report data=image

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Not sure I follow, you can put graphs and reports in a file, but you can't proc report a graph??  If you want an empty graph if there is no data, just add a rows where there is data, but with 0,0 or whatever the lowest is so it has a point to plot.

ods rtf file="Final.rtf";

ods graphics...;

/* If nobs is zero then create a file with one row of 0,0 */
data _null_;
  set sashelp.vtable (where=(libname="<yourlib>" and memname="<your ds>" and nobs=0));
  call execute('data  <yourlib>.<memname>; x=0; y=0; run;');
run;

proc sgplot data=<yourlib>.<your ds>...;
run;

proc report data=somethingelse...;
run;

ods rtf close;

Note, replace yourlib and your ds with the relevant names of your libs and datasets, for where's it should be upper case.

Ksharp
Super User
You can make a MACRO:


%let dsid=%sysfunc(open(input));
%let nobs=%sysfunc(attrn(&dsid,nlobs));
%let dsid=%sysfunc(close(&dsid));

%if &nobs ne 0 %then %do;
  ods graphics / reset=INDEX height=5in width=6in imagefmt=png imagename="F" border=off;
  proc sgplot data=input ...........................
%end;
%else %do;
  proc sgplot data=DUMMY..............
%end;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 3936 views
  • 0 likes
  • 4 in conversation