2 errors I don't understand

Reply
New Contributor
Posts: 2

2 errors I don't understand

I am on my last project for class and this program is the most confusing for me. I have to input the following into my code and I don't know what I am doing wrong. Could someone please help. Below is the log where my error is happening. 

 

66 PROC GLM DATA = mydata.coh602;

NOTE: Data file MYDATA.COH602.DATA is in a format that is native to another host, or the file encoding does not match the session
encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce
performance.
67 CLASS AHEDUC AK22_P;
68 MODEL DEPENDENT = AHEDUC AK22_P AHEDUC*AK22_P;
ERROR: Variable DEPENDENT not found.
NOTE: The previous statement has been deleted.
69 MEANS AHEDUC AK22_P / TUKEY;
ERROR: Effects used in the MEANS statement must have appeared previously in the MODEL statement.
NOTE: The previous statement has been deleted.
70 RUN;

 

Please any help would be greatly appreciated. 

Regular Contributor
Posts: 161

Re: 2 errors I don't understand

Check if the file exists. You can try to do a proc contents on the library or if you are using SAS EG or SAS University ED, or PC SAS, you may be able to browse the library panel to ensure the data exists and even browse to see if there is any issue with the SAS dataset. 

 

This would be the first step, I'd recommend. Once you resolve this, we can check the other errors if they continue to exist.

 

From your proc contents ensure the variables that are reported as not found exist or with a different name. 

 

Good Luck...!!!

 

Kannan Deivasigamani
New Contributor
Posts: 2

Re: 2 errors I don't understand

All varibles exist I am using them earlier in the program... here is the whole thing. so you can see.

 

LIBNAME mydata "/courses/d7085de5ba27fe300" access=readonly;
PROC CONTENTS DATA = mydata.coh602;
PROC UNIVARIATE DATA = mydata.coh602 ;
VAR SRAGE_P AK22_P AHEDUC AK1;
RUN ;
Proc gchart data= mydata.coh602 ;
VBAR SRAGE_P AK22_P AHEDUC AK1;
RUN ;
PROC FREQ DATA = mydata.coh602;
TABLES SRAGE_P AK22_P AHEDUC AK1;
PROC GLM DATA = mydata.coh602;
CLASS AHEDUC AK22_P;
MODEL DEPENDENT = AHEDUC AK22_P AHEDUC*AK22_P;
MEANS AHEDUC AK22_P / TUKEY;
RUN;

 

Just the PROC GLM section is where I am getting a hang up. any thoughts?

Trusted Advisor
Posts: 1,116

Re: 2 errors I don't understand

Thanks for providing more information. Actually, the output of the PROC CONTENTS step (line 2) would clarify everything.

 

You say, you are using "all variables" in your program. But where exactly is the place "earlier in the program" where you use variable DEPENDENT? The only place where I see it is in the MODEL statement in question.

Trusted Advisor
Posts: 1,116

Re: 2 errors I don't understand

Just to clarify my point before I go to bed (in Central Europe):

The output of your PROC CONTENTS step contained an "Alphabetic List of Variables and Attributes" for dataset MYDATA.COH602. If you review the column headed "Variable" in this list, you will find names such as "AHEDUC" and "AK22_P" (possibly not in upper case, but that doesn't matter, as SAS variable names are case insensitive). However, you will not find "DEPENDENT". In fact, SAS didn't find it "there" either -- and this is the issue.

 

Now I would ask you to look at the column headed "Label". If it exists (chances are good), this is the rightmost column in the table created by PROC CONTENTS. Here you will find descriptions of many if not all variables in MYDATA.COH602. Example: Variable AHEDUC could have something like "Educational status" (I guess). So, in the same column you will also find the description of the dependent variable of interest, say, "Body mass index" (if your research question is about factors influencing BMI). Then you read the corresponding variable name from column "Variable" in the same row. In this example it could be BMI_P. This would be the variable name that PROC GLM's MODEL statement requires on the left side of the equals sign.

Super User
Super User
Posts: 7,727

Re: 2 errors I don't understand

As a small note, please dont code all in capitals, it makes it twice as difficult to read, also use indentation and finish statements properly.  If your having trouble with code formatting, use the {i} or SAS run symbol above the box which will give you a code window.  

 

Your code reformatted would look lke the below:

libname mydata "/courses/d7085de5ba27fe300" access=readonly;

proc contents data = mydata.coh602;
run;

proc univariate data = mydata.coh602;
  var srage_p ak22_p aheduc ak1;
run;

proc gchart data= mydata.coh602;
  vbar srage_p ak22_p aheduc ak1;
run;

proc freq data = mydata.coh602;
  tables srage_p ak22_p aheduc ak1;
run;

proc glm data = mydata.coh602;
  class aheduc ak22_p;
  model dependent = aheduc ak22_p aheduc*ak22_p;
  means aheduc ak22_p / tukey;
run;

 

Trusted Advisor
Posts: 1,116

Re: 2 errors I don't understand

Don't worry. If your dataset hadn't existed, the CEDA note ("Cross Environment Data Access") would not have appeared.

 

The second error message is a mere consequence of the first: Since, as the log says, the MODEL statement has been "deleted" (i.e. has been ignored by SAS due to the first error), the "effects in the MEANS statement" have not "appeared previously in the MODEL statement", simply because there "is" no MODEL statement (anymore).

 

The first error will be simple to resolve, too: It just says that dataset MYDATA.COH602 does not contain a variable named "DEPENDENT". Given the cryptic names of the independent variables (which certainly refer to their contents), it would seem a bit surprising that the dependent variable has such a generic, non-informative name like "DEPENDENT". Just replace this name by the variable name corresponding to the quantity, whose linear relationship with AHEDUC and AK22_P you want to investigate.

Super User
Posts: 19,194

Re: 2 errors I don't understand

I'm going to assume you're using skeleton code from a professor or class.

I think you need to replace DEPENDENT with your dependent variable, whatever makes sense for your analysis.
The first 'error' isn't an error, just a warning that your dataset is in a different format, i.e. from UNIX to PC.

The second error is an error, there is no variable named DEPENDENT in your dataset.
Frequent Contributor
Posts: 108

Re: 2 errors I don't understand

Can you , provide the code and the sample data. I think you are using BY/Class statement and GLM is failing to classify it ..
Ask a Question
Discussion stats
  • 8 replies
  • 492 views
  • 2 likes
  • 6 in conversation