proc sgplot data= sahelp.heart;
vbar cause_of_death(repalce missing="unknown") /
group= Status
groupdisplay=cluster
run;
'cause_of_dealth' column contains missing values which is not displayed as separate label. I need to replace missing values in cause_of_dealth by 'unknown' and then plot vertical bar graph.But this code is not working. How to replace missing by unknown in this code.
Hi,
thank you for the solution. I used heart data set just an example, for my different code.I have the I need to give label 'unknown' to the missing values in vbar. How to label them, in the code below?
proc sgplot data=sashelp.heart; vbar DeathCause / group=Status groupdisplay=cluster missing; run;
Thanks for the help 😀
Hi @ratika2
In the SASHELP.HEART dataset, missing values for the DEATHCAUSE variable correspond to patients who are still alive. So I am not sure that it makes sense to consider their DEATHCAUSE as 'Unknown'.
If you still want to do that, I suggest that you write a DATA step first:
data heart;
set sashelp.heart;
if DeathCause="" then DeathCause="Unknown";
run;
proc sgplot data=heart;
vbar DeathCause / group=Status groupdisplay=cluster;
run;
But as I said, that doesn't make sense to me .
The use of the MISSING option would be more realistic:
proc sgplot data=sashelp.heart;
vbar DeathCause / group=Status groupdisplay=cluster missing;
run;
Best,
Hi,
thank you for the solution. I used heart data set just an example, for my different code.I have the I need to give label 'unknown' to the missing values in vbar. How to label them, in the code below?
proc sgplot data=sashelp.heart; vbar DeathCause / group=Status groupdisplay=cluster missing; run;
Thanks for the help 😀
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.