Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to convert char(date) to date to get noumber of months

Status
Not open for further replies.

KH75

Programmer
Jun 1, 2010
42
CA
Hi

I have text columns
date1 = 20135 (2013 is year and 5 is month)
date2 = 20109 (2010 is year and 9 is month)

I want to convert text in to date to get the number of months

I am using proc sql any idea how to do this in proc sql?

thanks
 
Well you could use the informat YYMMn. This will set the date value to the first of the month in question.

So in your case May 1, 2013

Here is an example that presumes that your variable with the '20135' value is named mydate.

proc sql;
create table test as
select *, input(mydate, yymmn6.) as mynewdate
from mydataset
;
quit;

I hope that this helps you.

Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top