Hi, I have a dataset with over 80,000 observations and I want to make a monthly box plot but get an error that the data isn't in order.
I want it to look like this:
I used this code:
proc boxplot data=dataname; plot Load*Month; run;
And here's how some of the data looks like and goes on for years:
input load day month temperature datalines: 12345 0 12 35 12456 1 12 33 12222 2 12 32 14532 3 12 31 15111 4 12 25 15222 5 12 24 15333 6 12 33 ;
The data step code you're trying to post is incomplete (in several posts now).
Try adding a PROC SORT to see if sorting the data fixes the issue. You should also consider switching to SGPLOT - better control of your graphics and higher quality graphs in general.
proc sort data=have;
by month;
run;
proc boxplot data=have;
plot load*month;
run;
proc sgplot data=have;
vbox load / category=month;
run;
@matt23 wrote:
Hi, I have a dataset with over 80,000 observations and I want to make a monthly box plot but get an error that the data isn't in order.
I want it to look like this:
I used this code:
proc boxplot data=dataname; plot Load*Month; run;And here's how some of the data looks like and goes on for years:
input load day month temperature datalines: 12345 0 12 35 12456 1 12 33 12222 2 12 32 14532 3 12 31 15111 4 12 25 15222 5 12 24 15333 6 12 33 ;
Since the values you display for the "day" axis are extremely unlikely given the "example data" , carefully edited to remove the data set name hiding the fact that you are plotting from a different data set where you have likely done some thing with the day an month variable we can't recreate what you have done.
Very likely you have created a character variable and then the "date" of 01Apr would be followed by 01Aug in sort order.
Hint: To have date related items sort in order then use actual DATE values. If you are looking for the spread of values for a given calendar day across years then assign the same year to all of the values and then use a date format to display the bit you want.
In your data step where you combined the day and month use:
Date = mdy(month, day, 1960);
format date date5. ; to show the date as ddMON
and then use the DATE variable for the x-axis variable.
Also is the "error" in the display or an actual SAS error message?
The data step code you're trying to post is incomplete (in several posts now).
Try adding a PROC SORT to see if sorting the data fixes the issue. You should also consider switching to SGPLOT - better control of your graphics and higher quality graphs in general.
proc sort data=have;
by month;
run;
proc boxplot data=have;
plot load*month;
run;
proc sgplot data=have;
vbox load / category=month;
run;
@matt23 wrote:
Hi, I have a dataset with over 80,000 observations and I want to make a monthly box plot but get an error that the data isn't in order.
I want it to look like this:
I used this code:
proc boxplot data=dataname; plot Load*Month; run;And here's how some of the data looks like and goes on for years:
input load day month temperature datalines: 12345 0 12 35 12456 1 12 33 12222 2 12 32 14532 3 12 31 15111 4 12 25 15222 5 12 24 15333 6 12 33 ;
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.