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

Dear all

I have a dataset with two dates as the example below.

I would like to create a variable X1=DATE2 - DATE1 (months).

How can I proceed?

Thanks in advance for any help

N

Date1

Date2

1

01/06/2006

05/06/2009

2

01/01/2006

28/03/2006

3

01/01/2002

15/01/2002

4

01/09/2007

02/10/2008

5

01/01/2000

02/02/2000

6

01/01/1993

15/01/1993

7

01/10/1989

15/10/1989

8

01/02/1998

01/07/1998

9

01/03/1998

12/03/1998

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Depending upon how you define number of months difference, you might be able to use something like:

data want;

  set have;

  months=intck('month',date1,date2,'c');

run;

View solution in original post

1 REPLY 1
art297
Opal | Level 21

Depending upon how you define number of months difference, you might be able to use something like:

data want;

  set have;

  months=intck('month',date1,date2,'c');

run;

sas-innovate-2024.png

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.

 

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