DATASET IS NOT AN OBJECT,how do i go about this error

416 views Asked by At

what's wrong with my code?

69         data train2.sacked; 
70                train2.payrise; 
71           set train2.exam (drop = test1 test2 test3 test4); 
72           mean2 = mean(test1, test2, test3, test4); 
73           if mean2 > 5 then 
74                     do 
75         result = 'PASS' 
76         action = 'Pay rise' 
77         output payrise; 
78   
79           if mean2 <= 5 then 
80                      do 
81                         result = 'LOSER' 
82         action = 'SACKED' 
83         output sacked; 
84   
85           else do 
86                          result = 'What have I done?' 
87          action = 'PARTY' 
88          output aahhhhh; 
89            length lname fname $ 40 result $ 20; 
90         run;

I try running the code but it gives me the error.

ERROR: DATA STEP Component Object failure.  Aborted during the COMPILATION phase.
ERROR 557-185: Variable train2 is not an object.
2

There are 2 answers

0
Tom On

The error is from the second statement.

train2.payrise; 

SAS thinks you are trying to reference a method of an object named TRAIN2 but the data step has not defined such an object (an example of an object in a data step is a HASH). I suspect that you meant that to be a dataset to include on the DATA statement but there is an extra semicolon in the middle of the DATA statement.

The rest of your program also has a lot of errors.

  • You are missing a lot of semicolons at the end of statements.
  • Your OUTPUT statements are trying to write to datasets not listed on the DATA statement.
  • You are trying to take the MEAN() of variables that you specifically told SAS to NOT load.
  • You are trying to set the length of character variables at the end of the data step. So either the variables existed and their length was already set so this attempt to change the length will fail. Or the variables will be created with all missing values since there is not code to assign them any values.
0
Reeza On

Here's the start of mistakes in your code. This will get you moving forward though I suspect you have more issues in your code.

  1. semicolon to early - this semicolon is unnecssary and limits your output to one data set
  2. Drop variables test1 to test4 which you attempt to use in the next step
  3. Attempt to use dropped variables
  4. Missing semicolon
  5. Missing END

69         data train2.sacked; /*1*/
70                train2.payrise; 
71           set train2.exam (drop = test1 test2 test3 test4);  /*2*/
72           mean2 = mean(test1, test2, test3, test4); /*3*/
73           if mean2 > 5 then 
74                     do /*4*/
75         result = 'PASS' /*4*/
76         action = 'Pay rise' /*4*/
77         output payrise; 
78                /*5*/
79           if mean2 <= 5 then 
80                      do /*4*/
81                         result = 'LOSER' /*4*/
82         action = 'SACKED' /*4*/
83         output sacked; 
84                /*5*/
85           else do /*4*/
86                          result = 'What have I done?' /*4*/
87          action = 'PARTY' /*4*/
88          output aahhhhh; 
                           /*5*/
89            length lname fname $ 40 result $ 20; 
90         run;