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.
Thank you,
Raja.B
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.
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.
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 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.