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

 

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. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ratika2
Fluorite | Level 6

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 😀

View solution in original post

2 REPLIES 2
ed_sas_member
Meteorite | Level 14

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;

Capture d’écran 2020-04-20 à 11.04.02.png

Best,

ratika2
Fluorite | Level 6

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 😀

SAS Innovate 2025: Register Now

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!

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
  • 6736 views
  • 1 like
  • 2 in conversation