BookmarkSubscribeRSS Feed
bits
Fluorite | Level 6

I want to use where statement to select a date between two character dates(date9.)..

what I have written is like:

data class1.dev_data1;                                                                                                                  
set class1.new_dev3;                                                                                                                  
where '01MAY2013'd < Loan_disbursement_date_ < '30APR2014'd;                                                                            
run; 

but it gives a error as "Where clause operator requires compatible variables".

 

 

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

Run

 

proc contents data = class1.new_dev3; 
run;

 

 

and see what type of variable Loan_disbursement_date_ is..

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Did you not ask the same question a few days back?  If not then there is a question from a few days back exactly the same.  What this is telling you is that the variable 

Loan_disbursement_date_ 

Is not a numeric variable.  Dates and times are numerics and you cannot compare something which is not numeric with numerics in that kind of logic sequence.  Fixing your data so that the date is actually a numeric SAS date would sort this, so would:

 

data class1.dev_data1;                                                                                                                  
  set class1.new_dev3;                                                                                                                  
  where '01MAY2013'd < input(Loan_disbursement_date_,date9.) < '30APR2014'd;                                                                            
run; 

Assuming that it is in date9. format. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 6912 views
  • 2 likes
  • 3 in conversation