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;
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;
Hi I tried that code but it does not bring back any records at all, the results table is blank
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).
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).
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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.