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.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1499 views
  • 2 likes
  • 3 in conversation