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

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. 

 

DateID
2000-12-28 1
2001-05-26
2002-06-12
1999-05-25 
2001-01-05 
2002-01-20 8
1998-05-17 
2007-06-20 
2008-04-26 10 
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

1 REPLY 1
Reeza
Super User

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1 reply
  • 813 views
  • 2 likes
  • 2 in conversation