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.)
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.