Hello Everyone,
I have a dataset with datevalues as shown below. I am trying to filter the dates which fall in certain range. How should I code this. For example, for the below dataset I need the date values in between 2001-01-01 and 2004-12-31.
Date | ID |
2000-12-28 | 1 |
2001-05-26 | 3 |
2002-06-12 | 4 |
1999-05-25 | 6 |
2001-01-05 | 7 |
2002-01-20 | 8 |
1998-05-17 | 5 |
2007-06-20 | 9 |
2008-04-26 | 10 |
If your dates are SAS dates (numeric with a date format) then filtering based on year should be fine.
where year(date) between 2000 and 2004;
Or
if 2000 <= year(date) <= 2004;
If your dates are SAS dates (numeric with a date format) then filtering based on year should be fine.
where year(date) between 2000 and 2004;
Or
if 2000 <= year(date) <= 2004;
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.
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.