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.

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 1685 views
  • 4 likes
  • 3 in conversation