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

Hello,

I'm currently trying to do what should be a simple task but the searches for proc expand and retain functions haven't been giving me the code that I need.

I currently have 3 columns, ID, Startdate, enddate, and I'd like to expand my dataset to fill in the months between my start and end dates.

For example:

ID          Startdate     Enddate

1           01/2001       03/2001

Would become:

ID          date

1          01/2001

1          02/2001

1          03/2001

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
tish
Calcite | Level 5

I assume that startdate and enddate are both SAS dates in mmyys7. format:

data new (keep=id date);

   set old;

   format date mmyys7.;

   do increment = 0 to intck('month', startdate, enddate);

      date = intnx('month', startdate, increment, 'beginning');

      output;

   end;

run;

View solution in original post

2 REPLIES 2
tish
Calcite | Level 5

I assume that startdate and enddate are both SAS dates in mmyys7. format:

data new (keep=id date);

   set old;

   format date mmyys7.;

   do increment = 0 to intck('month', startdate, enddate);

      date = intnx('month', startdate, increment, 'beginning');

      output;

   end;

run;

andp
Calcite | Level 5

Works exactly as I wanted! Thanks!

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
  • 2 replies
  • 3229 views
  • 0 likes
  • 2 in conversation