converting dates to numeric

Accepted Solution Solved
Reply
Super Contributor
Posts: 292
Accepted Solution

converting dates to numeric

How do I convert dates of this form 10/27/2006 to numeric? some dates are 2/2/2006?


Accepted Solutions
Solution
‎11-10-2014 12:41 PM
Trusted Advisor
Posts: 1,203

Re: converting dates to numeric

If I understood it correctly, you need number equivalent to the date then please try this.

data have;

input date mmddyy10.;

format  date mmddyy10.;

date_number=date;

datalines;

10/27/2006

;

View solution in original post


All Replies
Solution
‎11-10-2014 12:41 PM
Trusted Advisor
Posts: 1,203

Re: converting dates to numeric

If I understood it correctly, you need number equivalent to the date then please try this.

data have;

input date mmddyy10.;

format  date mmddyy10.;

date_number=date;

datalines;

10/27/2006

;

Super Contributor
Posts: 292

Re: converting dates to numeric

I do not understand, the data is imported from excel, the variable name is date.

Just as you said I need number equivalent to the date then please try this.

Trusted Advisor
Posts: 1,203

Re: converting dates to numeric

What is the type of date variable? Are you looking to convert char date variable into numeric or just need to know number which represents 10/27/2006?

Super Contributor
Posts: 292

Re: converting dates to numeric

A number 10/27/2006

Trusted Advisor
Posts: 1,203

Re: converting dates to numeric

What is the desired output?

☑ This topic is SOLVED.

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

Discussion stats
  • 5 replies
  • 301 views
  • 0 likes
  • 2 in conversation