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

Hello ,

 

I am Using Proc SGPLOT and i am stuck when data is zero obs when subject is missing from data

Please guide me how to display graph with X ,Y axis values with No data report in middle of graph box .

It will be better legends will dispaly.

 

I am using below code for sg plot.

 

raja777pharma_0-1599154978583.png

 

Thank you,

Raja.B

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Your example "code" is incomplete in that you show

%if &sqlobs > 0 %then %do;

but no matching end.

 

You would want a block of code inside.

%else %do;

%end;

Maybe something like:

%else %do;
Data dummy;
   x=48;
   y=3;
   text="No Data";
run;

proc sgplot data=dummy;
   text x=x y=y text=text;
   <your xaxis and yaxis go here
    as I am too lazy to retype
    everything
    >
run;
%end;

I picked x and y values should have the text appear near the middle of the graph with the XAXIS and YAXIS statements you showed. Feel free to play with them or the actual text of the text variable.

 

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

You really ought to provide the code as text pasted into the box that appears when you click on the "running man" icon, and not as a screen capture from now on.

 

To solve your problem, you would need to use a macro. You compute the number of observations in your data set. If the number of observations is above 0 (or above any number you choose) then you create the plot. Otherwise, you branch around the plot code.

--
Paige Miller
ballardw
Super User

Your example "code" is incomplete in that you show

%if &sqlobs > 0 %then %do;

but no matching end.

 

You would want a block of code inside.

%else %do;

%end;

Maybe something like:

%else %do;
Data dummy;
   x=48;
   y=3;
   text="No Data";
run;

proc sgplot data=dummy;
   text x=x y=y text=text;
   <your xaxis and yaxis go here
    as I am too lazy to retype
    everything
    >
run;
%end;

I picked x and y values should have the text appear near the middle of the graph with the XAXIS and YAXIS statements you showed. Feel free to play with them or the actual text of the text variable.

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 2 replies
  • 2125 views
  • 4 likes
  • 3 in conversation