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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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