Desktop productivity for business analysts and programmers

Dates in Character Format

Accepted Solution Solved
Reply
Contributor
Posts: 51
Accepted Solution

Dates in Character Format

Hello,

 

I've got some dates that I need to do use in filters and prompts.  They are month end dates stored as a string and they're in the format 0911 = 30 September 2011.  I'm struggling to convert the numbers to dates in a way that doesn't end up as 911 days after 1 Jan 1960.

 

I'm using Enterprise Guide 5.1 and would prefer a solution that I can use in a computed column.  I'd also like to know how to convert this into both Sep 2011 or 30 Sep 2011, I'm not sure which will be most useful at this stage.

 

Thanks! 


Accepted Solutions
Solution
‎02-01-2017 07:13 AM
Super User
Posts: 7,405

Re: Dates in Character Format

num_date = input('01'!!char_date,ddmmyy6.);
* now you have the first day of the month;
num_date = intnx('month',num_date,0,'end');
* now you have the last day of the month;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎02-01-2017 07:13 AM
Super User
Posts: 7,405

Re: Dates in Character Format

num_date = input('01'!!char_date,ddmmyy6.);
* now you have the first day of the month;
num_date = intnx('month',num_date,0,'end');
* now you have the last day of the month;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 51

Re: Dates in Character Format

Thanks, that's brilliant!

 

Once I'd remembered that || is concatenate I managed to work out what you were doing.  My problem was that I don't know SAS dates well enough to know whether 0911 can be a valid date, I assumed it could and ran into trouble.  Next time I'll know better!

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 184 views
  • 1 like
  • 2 in conversation