Hi all,
My hospital length of stays were in excel as '55:02:00' which are in hours and there must have previously been some character code in the column, because when I imported to SAS it changed to $31. and looks like '2.293055555555555556' except it's now in character. Any ideas how to convert it this into days (numeric?) and round up or down from the 10ths place.
Data have;
HLOS
55:02:00
203:46:00
192:42:00
data want;
HLOS (days)
2
9
8
@stancemcgraw Since you already have the number of days in character strings, give this a try.
data have;
input hlos $31.;
datalines;
2.293055555555555556
8.490277777777777
8.0291667
;
run;
data want;
set have;
hlos_numeric = round(input(hlos, 12.4), 1);
run;
(Also, I believe your second example would round off to 8 days, not 9.)
Since you already have the values as '2.293055555555555556', just take this character string and convert it into days
days=input(hlos,7.0);
If you want to round off, instead of truncate (which is what the above code will do), then you can modify the code properly.
@stancemcgraw Since you already have the number of days in character strings, give this a try.
data have;
input hlos $31.;
datalines;
2.293055555555555556
8.490277777777777
8.0291667
;
run;
data want;
set have;
hlos_numeric = round(input(hlos, 12.4), 1);
run;
(Also, I believe your second example would round off to 8 days, not 9.)
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.