Hi,
I am trying to convert AM/PM into military time. I've looked through past inquiries into this and the code is not working for me. As a couple of examples, the times are 7:00 AM and 5:55 AM. They are currently stored as character variables and the format that they are currently in is $9. Here's the code that I've been trying to get working:
data psqi3;
set psqi;
up_time=input(up_time, TIME8.);
format up_time time8.;
run;
1065
1066 data psqi3;
1067 set psqi;
1068 up_time=input(up_time, TIME8.);
1069 format up_time time8.;
------
48
ERROR 48-59: The format $TIME was not found or could not be loaded.
1070 run;
Does anyone have any thoughts on what I'm doing wrong here?
Thanks!
You input is defined as $9 then try up_time=input(up_time, TIME9.);
I have run next code as test :
data _NULL_;
length tmx $9;
tmx = '7:30 PM';
tm = input(tmx, time9.);
put tm time5.;
run;
log showed: 19:30
You can't use the same variable Name, you need to create a new variable to hold the numeric value of time.
Otherwise it should work.
This is because you can't change a variable type in SAS.
You input is defined as $9 then try up_time=input(up_time, TIME9.);
I have run next code as test :
data _NULL_;
length tmx $9;
tmx = '7:30 PM';
tm = input(tmx, time9.);
put tm time5.;
run;
log showed: 19:30
@Reeza is right.
The cause to error is not the length.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: