BookmarkSubscribeRSS Feed
R_Win
Calcite | Level 5
Hi
i have a date1 variable in this the observations was 05/01/07 and now i want to create another variable date2 and the observations shd be 05/02/07 up to end of that year as i have tried to add days to the first observation but the days diff from one month to anoher.

Here is the output:

date1 date2 date3 date4 ....... date12
05/01/07 05/02/07 05/03/07 05/04/07 .......................... 05/12/07 Message was edited by: Main
5 REPLIES 5
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
A SAS DATA step to increment your source variable by 1 while assigning a new DATE2 variable. A DO loop within the DATA step will provide logic to both assign the new variable and issue an OUTPUT with each loop iteration.

The SAS support http://support.sas.com/ website has SAS-hosted documentation and supplemental technical topic papers for reference. I used the SEARCH facility at the site and found several references - some pasted below.

Scott Barry
SBBWorks, Inc.

Looking for a Date? A Tutorial on Using SAS® Dates and Times
Arthur L. Carpenter, California Occidental Consultants
http://www2.sas.com/proceedings/sugi30/255-30.pdf

Working with Dates in the SAS System
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304321.htm
DanielSantos
Barite | Level 11
To increment a date value use the INTNX function.

See: http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000212700.htm

Greetings from Portugal.

Daniel Santos at www.cgd.pt
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
For consideration, using INTNX may be useful if incrementing a DATETIME variable by the date-portion, however having a DATE variable and incrementing sequentially (adding 1 increments to the next date) really does not require using INTNX.

Scott Barry
SBBWorks, Inc.
DanielSantos
Barite | Level 11
Scott is right, to add 1 day, you just need to increment the DATE variable by 1.

But, I think Main is having trouble to advance one month (quote: "...but the day diff from one month to anoher"), so in this case, INTNX would be the most simple way of doing it.

Cheers from Portugal.

Daniel Santos at www.cgd.pt
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
My mistake in not reading the post accurately. You make an excellent choice with using INTNX, Daniel.

Scott Barry
SBBWorks, Inc.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 962 views
  • 0 likes
  • 3 in conversation