DATA Step, Macro, Functions and more

Converting character date to numeric date

Reply
Contributor
Posts: 47

Converting character date to numeric date

I need to compare 2 date :

One of them is in character value 20$ and looks "2016-04-01 14:30:29"

Other one is numeric datettime20. and looks "05AUG2002:09:15:55"

 

i will compare them, how can i convert it?

 

Super User
Posts: 10,497

Re: Converting character date to numeric date

See if this approach works for you:

data junk;
   x="2016-04-01 14:30:29";
   y= dhms(input(scan(x,1,' '),yymmdd10.), 0,0,input(scan(x,2,' '),time.));
   format y datetime20.;
run;

Compare a variable make like Y to your other value.

 

Ask a Question
Discussion stats
  • 1 reply
  • 217 views
  • 0 likes
  • 2 in conversation