DATA Step, Macro, Functions and more

Error Variable not found

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Error Variable not found

Hello all,

 

I am trying to run logistic reg code but I am getting below error : 

 

NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

ERROR: Variable education not found.
NOTE: The SAS System stopped processing this step because of errors.
7 proc logistic data=work.bank1 desc;
8 model y= age job marital education default campaign cons_price_idx cons_conf_idx
8 ! euribor3m/ctable ;
9 run;

 

The error says education variable is missing but I can see the variable in bank1.xls file when open in sas.What can I do to resolve this issue?Below is the code I am running

 

proc logistic data=work.bank1 desc;
model y= age job marital education default campaign cons_price_idx cons_conf_idx euribor3m/ctable ;
run;

 

Please reply


Accepted Solutions
Solution
‎03-03-2016 05:21 PM
Trusted Advisor
Posts: 1,117

Re: Error Variable not found

That's exactly what I meant. So, the solution (regarding this specific error at least) is as simple as deleting the "n" in "education" in your PROC LOGISTIC step: educatio

View solution in original post


All Replies
Trusted Advisor
Posts: 1,117

Re: Error Variable not found

Hello @sgupta,

 

It's not enough that variable EDUCATION is contained in some Excel file. As a rule, for the PROC LOGISTIC step it's mandatory that this variable is also contained in the SAS dataset WORK.BANK1, i.e. in a file bank1.sas7bdat. You can check whether this is the case by submitting the following code:

proc contents data=work.bank1;
run;

What do you see in the output of the above PROC CONTENTS step?

Occasional Contributor
Posts: 9

Re: Error Variable not found

Posted in reply to FreelanceReinhard
I can see below output

[image: Inline image 1]

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Occasional Contributor
Posts: 9

Re: Error Variable not found

when I run it I can see 

 

under Alphabetic List of Variables and Attributes:

Variable       Type.......                                Label

EDUCATIO Num 8 BEST14. BEST14. EDUCATION

 

what does it mean.do i need to add something in code?

 

 

 

 

Solution
‎03-03-2016 05:21 PM
Trusted Advisor
Posts: 1,117

Re: Error Variable not found

That's exactly what I meant. So, the solution (regarding this specific error at least) is as simple as deleting the "n" in "education" in your PROC LOGISTIC step: educatio

Occasional Contributor
Posts: 9

Re: Error Variable not found

Posted in reply to FreelanceReinhard

Thanks 

I similarly changed other variables and I am able to see output now.

 

But can Run the original code with varibale names same as Label names?will adding label statement help?

Trusted Advisor
Posts: 1,117

Re: Error Variable not found

You're welcome.

 

No, you have to provide variable names to PROC LOGISTIC, not variable labels. Please note that variable labels, unlike variable names, may contain virtually any kind of special characters etc., which would cause nothing but problems.

 

If you don't like variable names such as educatio (which is the Latin word for "education", hence quite honorable :-) ), please feel free to rename your variables.

Super User
Posts: 11,343

Re: Error Variable not found


sgupta wrote:

 

But can Run the original code with varibale names same as Label names?will adding label statement help?


 

I assign labels to almost every variable in my permanent data sets because they make reading the results in procedures much easier. SAS will usually show at least some if not all of the next of the label in analysis procedures.

If I have a variable named age_ptt and that text appears in the output, I am about the only one that might know what it stands for. if I haven't used the data for a while I might not even remember. But if I associate a label age_ptt="Age Prior to Treatment", then when the label appears in a procedure output it has much better use.

 

The exceptions to adding label are variables such as Year, though if there are multiple year/date variables even that may get a label, and common data elements such as Phone or Zip.

Trusted Advisor
Posts: 1,117

Re: Error Variable not found

I'm sorry, but I can't see your output. It shows as text "[image: Inline image 1]" in my browser. Strange.

 

But the only relevant information is: Does the PROC CONTENTS output show a variable named EDUCATION (upper or lower case doesn't matter) or maybe only a variable whose label is "Education"?

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 1905 views
  • 5 likes
  • 3 in conversation