Help with create time variable

Accepted Solution Solved
Reply
Super Contributor
Posts: 371
Accepted Solution

Help with create time variable

Hi Everyone,

I simply want to create a time variable in my existing file and I don't know how to do it.

The variable in the format hh:mm:ss.

Could you quickly help me to fix it?

Thank you,

HHC

data a; set a;

time=0:00:00;

format time time11.;

run;


Accepted Solutions
Solution
‎09-07-2014 11:55 AM
Trusted Advisor
Posts: 1,203

Re: Help with create time variable

data a;

set a;

time='0:00:00't;

format time time11.;

run;

View solution in original post


All Replies
Solution
‎09-07-2014 11:55 AM
Trusted Advisor
Posts: 1,203

Re: Help with create time variable

data a;

set a;

time='0:00:00't;

format time time11.;

run;

Super User
Posts: 1,117

Re: Help with create time variable

Alternatively with format todw.d, the advantage of using todw.d format is that it will add the leading zeros to the time if they are missing from the collected or given time.


data test;
time='9:36't;
format time tod8.;
put time=;
run;


Thanks,

Jag

Thanks,
Jag
Grand Advisor
Posts: 17,396

Re: Help with create time variable

There's also the HMS() function, similar to MDY() function to create a time variable.

SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition

Super Contributor
Posts: 371

Re: Help with create time variable

Thank you for your help.

HHC

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 203 views
  • 6 likes
  • 4 in conversation