DATA Step, Macro, Functions and more

Splitting a hh:mm variable (numeric) in two variables hh and mm

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

Splitting a hh:mm variable (numeric) in two variables hh and mm

[ Edited ]

Hoping to get some help with this as I have spent hours searching to no avail!

 

I  have a numerical variable as hh:mm of the type  08:30 (time 5.) and would like to split into two num variables hh and mm so that I can do some recoding.

 

How does one do that? I have found out about splitting DD/MM/YY:hh:mm but that is not my case as dates are separate.

 

Hope you can help - thanks so much everyone for reading!


Accepted Solutions
Solution
‎06-07-2017 12:24 AM
Trusted Advisor
Posts: 1,137

Re: Splitting a hh:mm variable (numeric) in two variables hh and mm

Try the hour and minute functions as below

data want;
set have;
hour=hour(time);
minutes=minute(time);
run;
Thanks,
Jag

View solution in original post


All Replies
Solution
‎06-07-2017 12:24 AM
Trusted Advisor
Posts: 1,137

Re: Splitting a hh:mm variable (numeric) in two variables hh and mm

Try the hour and minute functions as below

data want;
set have;
hour=hour(time);
minutes=minute(time);
run;
Thanks,
Jag
Occasional Contributor
Posts: 12

Re: Splitting a hh:mm variable (numeric) in two variables hh and mm

Posted in reply to Jagadishkatam

Thanks so much - worked perfectly!

Super User
Posts: 11,343

Re: Splitting a hh:mm variable (numeric) in two variables hh and mm

It might be better to describe (i.e. show a few examples of) the sort of recoding you need. It may be that you do not need two additional variables at all.

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 129 views
  • 3 likes
  • 3 in conversation