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

Hi - I am trying to generate graph for categorical variables which has value of (missing, 0 and 1 for numeric value). Currently, I have a code which only displays the non-missing values (0,1) and I am wondering if sgplot need any instruction to display the missing bucket. 

 

FYI: My list of variable contains both numeric and character so depending on type, I will have  '.' for numeric and '' for character. 

 

Below is the code: 

 

 
DATA cars1;
infile DATALINES dsd missover;
 INPUT var val;
CARDS;
 ,0.2099
0,0.4749
1,0.7827
;
RUN;
proc sgplot data=cars1;
vbar var / response=val group=var
   datalabel datalabelattrs=(weight=bold);
 yaxis grid label='Actual Default Rate' ;
run;
DATA cars2;
infile DATALINES dsd missover;
 INPUT var $ val;
CARDS;
 ,0.2099
A,0.4749
B,0.7827
;
proc sgplot data=cars2;
vbar var / response=val group=var
   datalabel datalabelattrs=(weight=bold);
 yaxis grid label='Actual Default Rate' ;
run;
 
Can you please advice on how to include missing values on the sgplot? 
1 ACCEPTED SOLUTION

Accepted Solutions
jjjch
Obsidian | Level 7

add "missing" to your "vbar ... " statements. like below:

 

DATA cars1;
infile DATALINES dsd missover;
 INPUT var val;
CARDS;
 ,0.2099
0,0.4749
1,0.7827
;
RUN;
proc sgplot data=cars1;
vbar var / response=val group=var
   datalabel datalabelattrs=(weight=bold) missing;
 yaxis grid label='Actual Default Rate' ;
run;
DATA cars2;
infile DATALINES dsd missover;
 INPUT var $ val;
CARDS;
 ,0.2099
A,0.4749
B,0.7827
;
proc sgplot data=cars2;
vbar var / response=val group=var
   datalabel datalabelattrs=(weight=bold) missing;
 yaxis grid label='Actual Default Rate' ;
run;

 

View solution in original post

3 REPLIES 3
jjjch
Obsidian | Level 7

add "missing" to your "vbar ... " statements. like below:

 

DATA cars1;
infile DATALINES dsd missover;
 INPUT var val;
CARDS;
 ,0.2099
0,0.4749
1,0.7827
;
RUN;
proc sgplot data=cars1;
vbar var / response=val group=var
   datalabel datalabelattrs=(weight=bold) missing;
 yaxis grid label='Actual Default Rate' ;
run;
DATA cars2;
infile DATALINES dsd missover;
 INPUT var $ val;
CARDS;
 ,0.2099
A,0.4749
B,0.7827
;
proc sgplot data=cars2;
vbar var / response=val group=var
   datalabel datalabelattrs=(weight=bold) missing;
 yaxis grid label='Actual Default Rate' ;
run;

 

Pritish
Quartz | Level 8
Thank you very much!
Reeza
Super User
Please mark the question as solved by selecting the correct answer.

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
  • 3 replies
  • 1924 views
  • 2 likes
  • 3 in conversation