BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Babloo
Rhodochrosite | Level 12

Appreciate if some of you help me understand what the following where clause will do?

 

WHERE '31Jan2017'd between t1.PREMIUM_BEG_DT AND t1.PREMIUM_END_DT
1 ACCEPTED SOLUTION

Accepted Solutions
Satish_Parida
Lapis Lazuli | Level 10
It will filter records where PREMIUM_BEG_DT<31-Jan-2017 and PREMIUM_END_DT>31-Jan-2017

View solution in original post

3 REPLIES 3
Satish_Parida
Lapis Lazuli | Level 10
It will filter records where PREMIUM_BEG_DT<31-Jan-2017 and PREMIUM_END_DT>31-Jan-2017
RW9
Diamond | Level 26 RW9
Diamond | Level 26

This is basic SQL knowledge, perhaps have a read of the SQL in SAS help documents, or help documents on SQL:

https://www.w3schools.com/sql/sql_between.asp

s_lassen
Meteorite | Level 14

Basically, it will select all rows where the begin-date is before or on the 31st of January  2017, and the end date is on that date or after. If you are doing standard SQL, that is (in SAS, that happens if you write Pass-through SQL calls, or if the where clause is passed directly to an external DBMS).

 

But, if you are doing SAS SQL, it can also be the opposite, if the begin date is larger than the end date. Including if the end date is missing, and the begin date is after the date in question. SAS has a problem with missing values in where clauses, and with the between condition.

 

 

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