BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JamDOT
Calcite | Level 5

Here is my code:

proc format ;
value militarytimeN
00:00:00 - 01:00:00 ="12am-1am"
01:00:00-02:00:00="1am-2am"
02:00:00-03:00:00="2am-3am"
03:00:00-04:00:00="3am-4am"
04:00:00-05:00:00="4am-5am"
05:00:00-06:00:00="5am-6am"
06:00:00-07:00:00="6am-7am"
07:00:00-08:00:00="7am-8am"
08:00:00-09:00:00="8am-9am"
09:00:00-10:00:00="9am-10am"
10:00:00-11:00:00="10am-11am"
11:00:00-12:00:00="11am-12pm"
12:00:00-13:00:00="12pm-1pm"
13:00:00-14:00:00="1pm-2pm"
14:00:00-15:00:00="2pm-3pm"
15:00:00-16:00:00="3pm-4pm"
16:00:00-17:00:00="4pm-5pm"
17:00:00-18:00:00="5pm-6pm"
18:00:00-19:00:00="6pm-7pm"
19:00:00-20:00:00="7pm-8pm"
20:00:00-21:00:00="8pm-9pm"
21:00:00-22:00:00="9pm-10pm"
22:00:00-23:00:00="10pm-11pm"
23:00:00-24:00:00="11pm-11:59pm";
run;

Here is my error message:

 

proc format ;

332 value militarytimeN

333 00:00:00 - 01:00:00 ="12am-1am"

- -

22 200

200

ERROR 22-322: Syntax error, expecting one of the following: (, ',', -, <, =.

ERROR 200-322: The symbol is not recognized and will be ignored.

333! 00:00:00 - 01:00:00 ="12am-1am"

-

22

ERROR 22-322: Syntax error, expecting one of the following: (, ',', =......
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

You have to express those time values with the literal format:

 

proc format ;
value militarytimeN
'00:00:00't - '01:00:00't ="12am-1am"
/* same for remaining values */
;
run;

But you might also want to explore what existing time formats and precision specifiers can do for you, perhaps saving the trouble of a new format.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

View solution in original post

1 REPLY 1
ChrisHemedinger
Community Manager

You have to express those time values with the literal format:

 

proc format ;
value militarytimeN
'00:00:00't - '01:00:00't ="12am-1am"
/* same for remaining values */
;
run;

But you might also want to explore what existing time formats and precision specifiers can do for you, perhaps saving the trouble of a new format.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 966 views
  • 0 likes
  • 2 in conversation