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 😀
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: