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
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.
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
@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
Thank you it worked.
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!
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.