DATA Step, Macro, Functions and more

Need Help in Grouping Time

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 124
Accepted Solution

Need Help in Grouping Time

I have time in the format timeampm8.

 

For eg.  2:35 AM,  5:03 Am etc. etc.

 

I want to group the time as following :   "1 AM - 3 AM"

                                                              "3 AM - 5 AM"

                                                              "5 AM - 7 AM"

 

                                                                ---- etc.

 

 

 


Accepted Solutions
Solution
‎07-05-2016 10:30 PM
Contributor
Posts: 39

Re: Need Help in Grouping Time

Need to define & apply a format as follows

proc format;
value timerng
"01:00"t -< "03:00"t="1 AM - 3 AM"
"03:00"t -< "05:00"t="3 AM - 5 AM"
"05:00"t -< "07:00"t="5 AM - 7 AM";
*fill in the rest;
run;
data want;
format time timerng.;
time='01:35 AM't; output;
time='03:00 AM't; output;
time='03:02 AM't; output;
run;

View solution in original post


All Replies
Solution
‎07-05-2016 10:30 PM
Contributor
Posts: 39

Re: Need Help in Grouping Time

Need to define & apply a format as follows

proc format;
value timerng
"01:00"t -< "03:00"t="1 AM - 3 AM"
"03:00"t -< "05:00"t="3 AM - 5 AM"
"05:00"t -< "07:00"t="5 AM - 7 AM";
*fill in the rest;
run;
data want;
format time timerng.;
time='01:35 AM't; output;
time='03:00 AM't; output;
time='03:02 AM't; output;
run;
Frequent Contributor
Posts: 124

Re: Need Help in Grouping Time

Thanks John...

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 226 views
  • 0 likes
  • 2 in conversation