BookmarkSubscribeRSS Feed
robertrao
Quartz | Level 8

I have the dates like shown below used in the dataset and so I put those in Macro variables.

The date is numeric also

%let start =20130901;

%let end =20140831;

Could you help me understand why I am getting this kind of error?????

data Want;

set have(keep=Account Date Numerator Denominator);

where Numerator=1;

where same and Date between "&start"D and "&end"D ;

run;

ERROR: Invalid date/time/datetime constant "20130901"D.

ERROR: Invalid date/time/datetime constant "20140831"D.

ERROR: Syntax error while parsing WHERE clause.

NOTE: WHERE clause has been cleared.

Thanks

3 REPLIES 3
stat_sas
Ammonite | Level 13

What is "same"  in where clause?

ballardw
Super User

SAS date literals MUST be in the form ddMMMyy or ddMMMyyyy such as '31AUG2014'd NOT '20140831'D as you used them in the code.

jakarman
Barite | Level 11

Use date constants as documented.   Using mmm is the char abrevation not numbers.  SAS(R) 9.4 Language Reference: Concepts, Third Edition

SAS(R) 9.4 Statements: Reference, Third Edition

The constant  will be convert behind to a number. The date variable is coming in... same type? (you should know)

same is now a variable, new one, getting initialized with (missing). As a boolean it is false.

..... update: same is accepted syntax as is between with where statement.

Between an known with SQL SAS(R) 9.4 SQL Procedure User's Guide not in a normal datastep if statement SAS(R) 9.4 Language Reference: Concepts, Third Edition  

The between is however found at where processing SAS(R) 9.4 Language Reference: Concepts, Third Edition

The same and is also there.  Nice, getting the old interactive approach back from my memory (FSP). 
I only do not understand the "same and" coding in a batch/code programming way

---->-- ja karman --<-----

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 842 views
  • 0 likes
  • 4 in conversation