BookmarkSubscribeRSS Feed
user_38qp
Calcite | Level 5

proc sgplot data=votes;
vbox savings / category=poverty;
xaxis type=discreate values=('0-10' '11-20' '21-30' '31-40' '41-50');
run;

 

above is the code i am using when trying to create a boxplot but it comes out blank. Any ideas why?

The dataset has a savings column and a poverty column

 

4 REPLIES 4
ballardw
Super User

My first thought would be the values of your category variable is a likely cause.

Is "poverty" a numeric variable that you are attempting to group into values of 1-10 for the plot? If so you might be better off with a custom format to create the groups.

 

Otherwise show a set of data that we can duplicate the behavior of the code with.

user_38qp
Calcite | Level 5
savingsincomepoverty
576231576815.2
849351695413.6
836561553225
612491482015
757251112033
758871201527.1
760731516218

 

Here is a sample of it

 

thank you for your assistance

ballardw
Super User

@user_38qp wrote:
savings income poverty
57623 15768 15.2
84935 16954 13.6
83656 15532 25
61249 14820 15
75725 11120 33
75887 12015 27.1
76073 15162 18

 

Here is a sample of it

 

thank you for your assistance


So the reason your plot failed was none of the values of poverty matched the values of the value list in the axis statement.

Try this:

proc format library=work;
value povgrp 
 0   -<11 = ' 0-10'
 11  -<21 = '11-20'
 21  -<31 = '21-30'
 31  -<41 = '31-40'
 41  -<51 = '41-50'
;
run;

proc sgplot data=votes;
   vbox savings / category=poverty;
   format poverty povgrp.;
run;

the custom format will create groups of values

 

user_38qp
Calcite | Level 5

Thank you it worked. 

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
  • 4 replies
  • 658 views
  • 0 likes
  • 2 in conversation