BookmarkSubscribeRSS Feed
sophia_SAS
Obsidian | Level 7

Hi SAS users,

I have a dataset with 3 variables: ID, date1 and date2.  I would like to create a new dataset that identifies which observations have a date2 that is 5 months or greater than date1.  For example using the data below, I would like to identify IDs 7 and 11 as they have a date2 that is at least 5 months greater than date1.

Thanks.

data have;

input id           date1                   date2;

cards;

          5     05/12/2010          06/12/2010

          7     06/22/2010          12/30/2010

          9     02/04/2009          05/03/2009

          11   03/27/2009          11/05/2009

;

run;

2 REPLIES 2
Linlin
Lapis Lazuli | Level 10

try this one:

data have;

informat date1 date2 mmddyy10.;

format date1 date2 mmddyy10.;

input id date1 date2;

cards;

          5     05/12/2010          06/12/2010

          7     06/22/2010          12/30/2010

          9     02/04/2009          05/03/2009

          11   03/27/2009          11/05/2009

;

data want;

  set have;

  if date2>intnx('month',date1,5,'s');

proc print;run;

Linlin

sophia_SAS
Obsidian | Level 7

Thanks LinLin!  Always very helpful!

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 708 views
  • 1 like
  • 2 in conversation