Learning SAS? Welcome to the exclusive online community for all SAS learners.

Error messages from Contrast Analysis

Reply
New Contributor
Posts: 4

Error messages from Contrast Analysis

I have agricultural data on the effect of crop species on soil organic matter. The treatments are qualitative and structured, I therefore aimed at planned contrast analysis. I adapted the code example in SAS/STAT User's Guide, Vol. 2, Version 6, 4th Ed., page 965. Unfortunately the results are incomplete, and I get 11 warning messages in the LOG.  I have been unable to find out what is wrong. I even copy-pasted SAS own data and code referenced above, and  still get error messages. I wonder what is wrong? The results only display 5 contrasts instead of the 11 input....

Below are the screen shots of my adapted CODE and LOG:

Part 1 CODEPart 1 CODEPart 2 CODEPart 2 CODEPART 1 LOGPART 1 LOGPart 3 LOGPart 3 LOGPart 4 LOGPart 4 LOGPart 2 LOGPart 2 LOG

Super User
Posts: 10,874

Re: Error messages from Contrast Analysis

You will get much better hellp posting code and log as actual text instead of pictures. We can't test "pictures" and most of us don't have the time to retype all of your example.

 

Your diagnostic from the log on reading data looks like some of your lines have tab characters (the zone=0 and numr=9) where the diagnostic shows a . appearing. That may becausing issues with where the breaks between variables are actually being treated.

The "SAS went to a new line" says that for some reason SAS tried to read more values from a single line than exist.

You likely need a simple

input;

afte the end of the do Block; because the late read with @ is still attempting to read from that line.

New Contributor
Posts: 4

Re: Error messages from Contrast Analysis

Thanks Ballardw and Reeza,

I have been trying for weeks already to figure out what is wrong... I am stuck

As advised, please find and try out below the text version of the code:

CODE:

Title '2008-2016 Contrast SOM, Energy Crops at Elora station UoG' ;
data OMatter;
input Crop $ @;
do block=1 to 3;
input orga @;
output;
end;
cards;
CORNON  2.5  2.2  2.3
WIlON        2.6  2.5  2.0
SWION      3.0  3.4  3.4
MISON      3.5  3.5  3.6
CORNFER 3.2  3.0  2.9
WILFER     2.8  3.0  2.9
SWIFER    3.1  3.6   3.5
KNOXER   3.4  3.6   3.7
CORNCON  2.3  2.0  1.9
WILCON      2.0   2.1  1.8
SWICON     2.2   2.3   2.0
MISCON     2.3    2.0   2.2
;
proc glm;
class Crop block;
model orga=Crop block;
run;

proc glm order=data;
class Crop block;
model orga=Crop block / solution;

/*-Crop-order--------------------cso-wilo-swo-miso-csN-wilN-swN-knox-contra-contrb-contrc-contrd */
contrast '16 vs 08' Crop 1 1 1 1 1 1 1 1 -2 -2 -2 -2;
contrast '16-0 vs 16-80' Crop 1 1 1 1 -1 -1 -1 -1 0 0 0 0;
contrast '16-0 vs 08-0' Crop 1 1 1 1 0 0 0 0 -1 -1 -1 -1;
contrast '16-80 vs 08-0' Crop 0 0 0 0 1 1 1 1 -1 -1 -1 -1;
contrast 'grass vs 08-0' Crop 0 0 1 1 0 0 1 1 -1 -1 -1 -1;
contrast 'grass vs other' Crop -1 -1 1 1 -1 -1 1 1 0 0 0 0;
contrast 'cs vs 08-0' Crop 2 0 0 0 2 0 0 0 -1 -1 -1 -1;
contrast 'cs vs others' Crop 3 -1 -1 -1 3 -1 -1 -1 0 0 0 0;
contrast 'wil vs 08-0' Crop 0 2 0 0 0 2 0 0 -1 -1 -1 -1;
contrast 'wil vs others' Crop -1 3 -1 -1 -1 3 -1 -1 0 0 0 0;
contrast 'gras0 vs gras80' Crop 0 0 1 1 0 0 -1 -1 0 0 0 0;
run;
means Crop / waller regwq;
run;

 

Super User
Posts: 18,588

Re: Error messages from Contrast Analysis

Your code without errors. 

 

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 61         
 62         data OMatter;
 63         input Crop $ @;
 64         do block=1 to 3;
 65         input orga @;
 66         output;
 67         end;
 68         cards;
 
 NOTE: The data set WORK.OMATTER has 36 observations and 3 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 81         ;
 
 82         proc glm;
 83         class Crop block;
 84         model orga=Crop block;
 85         run;
 
 
 NOTE: PROCEDURE GLM used (Total process time):
       real time           7.78 seconds
       cpu time            0.73 seconds
       
 86         proc glm order=data;
 
 87         class Crop block;
 88         model orga=Crop block / solution;
 89         /*-Crop-order--------------------cso-wilo-swo-miso-csN-wilN-swN-knox-contra-contrb-contrc-contrd */
 90         contrast '16 vs 08' Crop 1 1 1 1 1 1 1 1 -2 -2 -2 -2;
 91         contrast '16-0 vs 16-80' Crop 1 1 1 1 -1 -1 -1 -1 0 0 0 0;
 92         contrast '16-0 vs 08-0' Crop 1 1 1 1 0 0 0 0 -1 -1 -1 -1;
 93         contrast '16-80 vs 08-0' Crop 0 0 0 0 1 1 1 1 -1 -1 -1 -1;
 94         contrast 'grass vs 08-0' Crop 0 0 1 1 0 0 1 1 -1 -1 -1 -1;
 95         contrast 'grass vs other' Crop -1 -1 1 1 -1 -1 1 1 0 0 0 0;
 96         contrast 'cs vs 08-0' Crop 2 0 0 0 2 0 0 0 -1 -1 -1 -1;
 97         contrast 'cs vs others' Crop 3 -1 -1 -1 3 -1 -1 -1 0 0 0 0;
 98         contrast 'wil vs 08-0' Crop 0 2 0 0 0 2 0 0 -1 -1 -1 -1;
 99         contrast 'wil vs others' Crop -1 3 -1 -1 -1 3 -1 -1 0 0 0 0;
 100        contrast 'gras0 vs gras80' Crop 0 0 1 1 0 0 -1 -1 0 0 0 0;
 101        run;
 
 102        means Crop / waller regwq;
 103        run;
 
 NOTE: Means from the MEANS statement are not adjusted for other terms in the model.  For adjusted means, use the LSMEANS statement.
 104        
 105        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 118        
New Contributor
Posts: 4

Re: Error messages from Contrast Analysis

Hello, thanks!

Although the errors messages have disappeared with the new code, there are warning messages, and the contrast analysis are incomplete, only 5 contrasts are displayed instead of 11.

 

here is the log; (I wonder why it says data invalid...). Did you get in the results the full set of contrasts?

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 Title '2008-2016 Contrast SOM, Energy Crops at Elora station UoG' ;
63 data OMatter;
64 input Crop $ @;
65 do block=1 to 3;
66 input orga @;
67 output;
68 end;
69 cards;
 
NOTE: Invalid data for orga in line 76 18-25.
NOTE: Invalid data for orga in line 77 1-7.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
 
77 CHAR KNOXER. .3.4. 3.6..3.7
ZONE 44454502032302222323003232222222222222222222222222222222222222222222222222222222
NUMR BEF8529093E4900003E6993E70000000000000000000000000000000000000000000000000000000
Crop=SWIFER block=4 orga=. _ERROR_=1 _N_=7
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.OMATTER has 33 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
 
82 ;
 
83 proc glm;
84 class Crop block;
85 model orga=Crop block;
86 run;
 
87
 
NOTE: PROCEDURE GLM used (Total process time):
real time 1.24 seconds
cpu time 0.68 seconds
 
88 proc glm order=data;
 
89 class Crop block;
90 model orga=Crop block / solution;
91
92 /*-Crop-order--------------------cso-wilo-swo-miso-csN-wilN-swN-knox-contra-contrb-contrc-contrd */
93 contrast '16 vs 08' Crop 1 1 1 1 1 1 1 1 -2 -2 -2 -2;
94 contrast '16-0 vs 16-80' Crop 1 1 1 1 -1 -1 -1 -1 0 0 0 0;
95 contrast '16-0 vs 08-0' Crop 1 1 1 1 0 0 0 0 -1 -1 -1 -1;
96 contrast '16-80 vs 08-0' Crop 0 0 0 0 1 1 1 1 -1 -1 -1 -1;
97 contrast 'grass vs 08-0' Crop 0 0 1 1 0 0 1 1 -1 -1 -1 -1;
98 contrast 'grass vs other' Crop -1 -1 1 1 -1 -1 1 1 0 0 0 0;
99 contrast 'cs vs 08-0' Crop 2 0 0 0 2 0 0 0 -1 -1 -1 -1;
100 contrast 'cs vs others' Crop 3 -1 -1 -1 3 -1 -1 -1 0 0 0 0;
101 contrast 'wil vs 08-0' Crop 0 2 0 0 0 2 0 0 -1 -1 -1 -1;
102 contrast 'wil vs others' Crop -1 3 -1 -1 -1 3 -1 -1 0 0 0 0;
103 contrast 'gras0 vs gras80' Crop 0 0 1 1 0 0 -1 -1 0 0 0 0;
104 run;
 
WARNING: More coefficients than levels specified for effect Crop. Some coefficients will be ignored.
NOTE: CONTRAST 16 vs 08 is not estimable.
WARNING: More coefficients than levels specified for effect Crop. Some coefficients will be ignored.
WARNING: More coefficients than levels specified for effect Crop. Some coefficients will be ignored.
NOTE: CONTRAST 16-0 vs 08-0 is not estimable.
WARNING: More coefficients than levels specified for effect Crop. Some coefficients will be ignored.
NOTE: CONTRAST 16-80 vs 08-0 is not estimable.
WARNING: More coefficients than levels specified for effect Crop. Some coefficients will be ignored.
NOTE: CONTRAST grass vs 08-0 is not estimable.
WARNING: More coefficients than levels specified for effect Crop. Some coefficients will be ignored.
WARNING: More coefficients than levels specified for effect Crop. Some coefficients will be ignored.
NOTE: CONTRAST cs vs 08-0 is not estimable.
WARNING: More coefficients than levels specified for effect Crop. Some coefficients will be ignored.
WARNING: More coefficients than levels specified for effect Crop. Some coefficients will be ignored.
NOTE: CONTRAST wil vs 08-0 is not estimable.
WARNING: More coefficients than levels specified for effect Crop. Some coefficients will be ignored.
WARNING: More coefficients than levels specified for effect Crop. Some coefficients will be ignored.
105
106 means Crop / waller regwq;
107 run;
 
NOTE: Means from the MEANS statement are not adjusted for other terms in the model. For adjusted means, use the LSMEANS statement.
108 means Crop / waller regwq;
109 run;
 
NOTE: Means from the MEANS statement are not adjusted for other terms in the model. For adjusted means, use the LSMEANS statement.
110
111
112
113
114
115 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
128
Super User
Posts: 18,588

Re: Error messages from Contrast Analysis

Your data is still being read in correctly, leading to further incorrect results. 

I'm not sure why, but I would suggest typing out the code instead of copying/pasting. I suspect you're having issues with some sort of invisible character that's messing up your code.

Super User
Posts: 18,588

Re: Error messages from Contrast Analysis

I suspect your data was not read in correctly. Fix your errors in the order the appear from the top of the log to the bottom. You may still have contrast errros after, but you definitely will have the wrong answers if the data is not read correctly.

New Contributor
Posts: 4

Re: Error messages from Contrast Analysis

I wonder if there is specific rules in entering data with respect to spacing between names and numbers?

 

Rosichrist

Ask a Question
Discussion stats
  • 7 replies
  • 179 views
  • 2 likes
  • 3 in conversation