Hi,
I would like to be able to select data where the 'send date' of my dataset refers to the last 3 weeks from today.
Thanks.
Hi,
Please show what code you have tried, and describe why it didn't work (did you get an error? did you get a surprising result?).
Also, please define your selection criteria more precisely. Do you want to select all records where FECHA_ENVIO is within 21 days of today's date (the date the program is run)?
Perhaps:
if (today() - datepart(fecha_envio)) <=21 ;
I have executed the command you say and it does not give me an error but it does not give me the expected result.
The datetimes you show are ALL before three weeks before today.
Not all
Log:
@albribmun wrote:
Not all
And as your log tells you, 885 observations met the condition and were read and written to the new dataset.
Please do not post pictures. Copy/paste log text to a window opened with this button:
To supply example data for our use in developing and testing code, use a data step with datalines, and post it as text in a window opened with the "little running man" right next to the one indicated.
Note that TODAY() is just an alias for the DATE() function.
So the function TODAY() returns a DATE value (number of days since 1960).
The DTDAY interval works with DATETIME values (number of seconds since 1960).
If you treat the number of days since 1960 as the number of seconds since 1960 you get some time early on January 1,1960.
If you want the current datetime value use the DATETIME() function.
Yes, I want to get all records for all other variables where the date is between the last 3 weeks. The code does not give me error, but the table is not displayed.
I have already found the solution using this:
if intck('week', today(), datepart(fecha_envio)) ge -3
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.