DATA Step, Macro, Functions and more

Extracting Observations between a Begin and End Date

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Extracting Observations between a Begin and End Date

Hello,

 

I have a data that looks like 

 

ID        Birthdate

1          4/1/1978

2          5/1/1980

3          1/1/1990

4          5/1/1983

5          7/12/1991

 

I want to create an output dataset that has subjects born between 3/11/1980 to 8/1/1991

 

What is a simple and straightforward way to do this?

 

Thank you so much.

gary

 


Accepted Solutions
Solution
‎11-17-2017 02:50 PM
Super User
Posts: 10,544

Re: Extracting Observations between a Begin and End Date

Posted in reply to pegasus1225

If your birthdate variable is a SAS date variable:

data want;
set have;
where '11mar1980'd <= birthdate <= '01aug1991'd;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Solution
‎11-17-2017 02:50 PM
Super User
Posts: 10,544

Re: Extracting Observations between a Begin and End Date

Posted in reply to pegasus1225

If your birthdate variable is a SAS date variable:

data want;
set have;
where '11mar1980'd <= birthdate <= '01aug1991'd;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 95 views
  • 0 likes
  • 2 in conversation