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 😀

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