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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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