BookmarkSubscribeRSS Feed
Martina4
Calcite | Level 5

Hello all,

 

I am trying to gather the means and standard errors of my treatments for my data. I have entered the following code...

proc means data=WORK.yr1_2016 mean stderr;
var totyd sorgyd weedyd legyd;
by leg;
output out = b mean=totalydX sorgydX weedydX legydX stderr=totalydSE sorgydSE weedydSE legydSE;
run;

 

However, I keep receiving the following error message when I try to run it...

ERROR: Data set WORK.YR1_2016 is not sorted in ascending sequence. The current BY group has leg = RHL and the next BY group has leg
= ALF.
This experiment is a randomized split-plot arrangement. There are six main plots listed under "leg" and the six plots are ALF, BFT, IBF, PPC, RD, RHL. And then there are four split plots listed under CC and these are 1, 2, 3, and 4. There is a significant leg*CC interaction if this makes any difference in the above coding.
 
Thank you!

 

4 REPLIES 4
Reeza
Super User
If you use a BY statement you do have to sort your data so that the BY groups are in order in your data. If you do not want to dot his for some reason you can switch By to CLASS.
For the sort, just make sure your BY statement is the same in the proc as in PROC SORT.

proc sort data=yr1_2016;
by leg; run;

Note that you do not need to specify the statistics in the PROC MEANS statement, this only controls the displayed output.
kyle2356
Calcite | Level 5
Thank you so much, I'm new to SAS and this was really helpful for my purposes.
Astounding
PROC Star

Also note, if you switch from BY to CLASS:

 

class leg;

 

The CLASS statement produces extra summarizations that you would not otherwise get.  If you want just a summarization for each LEG, you have to apply the nway option:

 

proc means data=WORK.yr1_2016 nway; 

PaigeMiller
Diamond | Level 26

@Martina4 wrote:
 
This experiment is a randomized split-plot arrangement. There are six main plots listed under "leg" and the six plots are ALF, BFT, IBF, PPC, RD, RHL. And then there are four split plots listed under CC and these are 1, 2, 3, and 4. There is a significant leg*CC interaction if this makes any difference in the above coding.

While this description doesn't directly indicate any sorting, you can also try

 

by leg notsorted;

 

This requires all the RHL to be consecutive and all the ALF to be consecutive, and so on.

--
Paige Miller

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 26503 views
  • 7 likes
  • 5 in conversation