DATA Step, Macro, Functions and more

Error in Where clause in data step

Reply
Occasional Contributor
Posts: 13

Error in Where clause in data step

[ Edited ]

I am runing following code,

 

libname orionx XLSX "/home/aniketwagare0/test/ecprg193/lpar.xlsx"
libname outori "/home/aniketwagare0/test/output"

data outori.tetest
set orionx.lpar1
where Action Performed='111 Create an account' and Action Performed='109 Subscribe Email'
run

 

But i am getting following error,

 

57 data outori.tetest;
58 set orionx.lpar1;
59 where Action_Performed='111 Create an account' and Action_Performed='109 Subscribe Email'
ERROR: Variable Action_Performed is not on file ORIONX.lpar1.
60 run;
 
 
I have attached my xlsx file.
Super User
Posts: 11,343

Re: data step

Posted in reply to aniketwagare0

Check your spelling. Make sure the variable you reference is the same. I will bet that there is no _ in the name of the variables (or a space either)

Super User
Posts: 19,772

Re: data step

Posted in reply to aniketwagare0

Your condition will never be true. 

 

If one portion is true the other will not be true. 

 

Perhaps you mean OR instead of AND?

 

You can also use IN

 

where actionPerformed in ('match1' , 'match2', 'match3');

Super User
Posts: 7,768

Re: Error in Where clause in data step

Posted in reply to aniketwagare0

This

ERROR: Variable Action_Performed is not on file ORIONX.lpar1.

tells the whole story. You mistyped the variable name.

Before working with Excel files through SAS, one should make sure that the header lines in the sheets (which are used to create variable names) adhere to SAS naming standards.

I'd rather import the Excel data into SAS (preferably by saving to a proper file format like csv from Excel) and deal with issues there.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 3 replies
  • 244 views
  • 2 likes
  • 4 in conversation