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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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