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

Hello,

 

How to select the people less than 5 days in the 'Birthdate' column?  For example, 02/25/2020 <= 5 days.

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

Please always provide some sample data in the form of a SAS datastep.

Below should give you the idea.

data have;
  input birthdate :date9.;
  format birthdate date9.;
  datalines;
01feb2000
20feb2001
27feb2002
05mar2003
;

data want;
  set have;
  _yearShift=intck('year',birthdate,today());
  _birthdate=intnx('year',birthdate,_yearShift,'s');
  format _birthdate date9.;
  diff=today()-_birthdate;
/*  if abs(diff)<=5 then output;*/
run;

proc print;
run;

 

View solution in original post

2 REPLIES 2
Patrick
Opal | Level 21

Please always provide some sample data in the form of a SAS datastep.

Below should give you the idea.

data have;
  input birthdate :date9.;
  format birthdate date9.;
  datalines;
01feb2000
20feb2001
27feb2002
05mar2003
;

data want;
  set have;
  _yearShift=intck('year',birthdate,today());
  _birthdate=intnx('year',birthdate,_yearShift,'s');
  format _birthdate date9.;
  diff=today()-_birthdate;
/*  if abs(diff)<=5 then output;*/
run;

proc print;
run;

 

ybz12003
Rhodochrosite | Level 12

Thank you.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 402 views
  • 1 like
  • 2 in conversation