BookmarkSubscribeRSS Feed
zdassu
Quartz | Level 8

Hi I am trying to bring back data between two dates using the today() function. I don't think I can do this in Data step but is there an equivalent that I can use. See code that I have created below

data work.tempA;
keep Name_Id Address_Id;
set work.tempb;
WHERE is_current_flg = 1 AND record_deleted_flg = 0
AND today()between Valid_From_Dt and Valid_To_Dt;
run;
6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20
data work.tempA;
keep Name_Id Address_Id;
set work.tempb;
WHERE is_current_flg = 1 AND record_deleted_flg = 0
AND Valid_From_Dt le today() le Valid_To_Dt;
run;
zdassu
Quartz | Level 8

Hi I tried that code but it does not bring back any records at all, the results table is blank

Tom
Super User Tom
Super User

Can you find an example that you think it should have found?

Please show the example data that fails to get selected but that you think it should select.

 

Make sure that the variables in your dataset are DATES (not strings, not datetime values, not numbers that humans might mistake for dates).

Tom
Super User Tom
Super User

Did it not work?  If so how? Did you get an error?  Not get the expected results?  Show example data that you though met the WHERE condition and didn't get selected (or the reverse).

Kurt_Bremser
Super User

Maxim 3: Know Your Data.

Are valid_from_dt and valid_to_dt SAS date values (numeric, with a date format attached)? If yes, run a proc freq on those columns to see which values they contain.

Reeza
Super User
TODAY() returns today's date, of July 17. Are you sure that's what you want to be doing?

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 6 replies
  • 943 views
  • 0 likes
  • 5 in conversation