Increment char date YYYYMMDD by 1

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

Increment char date YYYYMMDD by 1

[ Edited ]

Hello,

 

Please can you assist me with the following problem:

 

I would like to increment a date that is stored in the format YYYYMMDD $8. by one day. I have tried converting using YYMMDD8. however all I get is ******* as a date output.

 

Sample input: 201611030

Output required: 20161201

 

Any help would be greatly appreciated.

 

Thank you.


Accepted Solutions
Solution
‎12-01-2016 07:30 AM
Super User
Posts: 5,372

Re: Increment char date YYYYMMDD by 1

You're probably missing an "N":

 

chardate = put( input(chardate, yymmdd8.) + 1, yymmddn8.);

 

The "N" says that the format should contain no delimiters where SAS might have used a dash or a slash.

View solution in original post


All Replies
Solution
‎12-01-2016 07:30 AM
Super User
Posts: 5,372

Re: Increment char date YYYYMMDD by 1

You're probably missing an "N":

 

chardate = put( input(chardate, yymmdd8.) + 1, yymmddn8.);

 

The "N" says that the format should contain no delimiters where SAS might have used a dash or a slash.

Contributor
Posts: 25

Re: Increment char date YYYYMMDD by 1

Thank you very much!
Super User
Super User
Posts: 7,736

Re: Increment char date YYYYMMDD by 1

Why do you have a date stored as text, your just creating issues for yourself there.

Contributor
Posts: 25

Re: Increment char date YYYYMMDD by 1

It is a functional requirement however I agree with your questioning.


☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 229 views
  • 0 likes
  • 3 in conversation