BookmarkSubscribeRSS Feed
robertrao
Quartz | Level 8

Hello ,

 

I have written this code and it says Syntax Error. I dont find anything wrong. Could someone review and let me know the issue?

 

proc format;

value $surg

'10021'-'10180', '11000'-'11057'

'11100'-'11312', '11313'-'11442'

'11443'-'11621', '11622'-'11772'= 1

other=0;

run;

 

Thanks so much

4 REPLIES 4
Astounding
PROC Star

The output of a format is a character string.  The values "1" and "0" need quotes.  

 

If you want a numeric output, you will need to create an informat instead of a format.

robertrao
Quartz | Level 8

Hello Astounding,

 

Thansk fo rth ereply. Even after I put the quotes I have a syntax error!!

 

812 proc format;

813 value $surgeries

814 '10021'-'10180', '11000'-'11057'

815 '11100'-'11312', '11313'-'11442'

-

22

76

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

ERROR 76-322: Syntax error, statement will be ignored.

816 '11443'-'11621', '11622'-'11772'= "1"

817 other="0";

NOTE: The previous statement has been deleted.

818 run;

NOTE: PROCEDURE FORMAT used (Total process time):

real time 0.00 seconds

user cpu time 0.00 seconds

system cpu time 0.00 seconds

memory 89.46k

OS Memory 23284.00k

Timestamp 11/11/2016 02:25:03 PM

Step Count 36 Switch Count 0

NOTE: The SAS System stopped processing this step because of errors.

 

robertrao
Quartz | Level 8

Hello Astounding,

 

It worked. I was misssing a comma between those format pairs.

Just curious that it worked fine even without putting quotes for The values "1" and "0" . Do i need to know anything regarding this?

 

Thanks

Astounding
PROC Star

Just think of it in the right way ... a format is always a set of characters, because it is a way to express the actual value of a variable.  If you want a numeric result, use an INVALUE statement instead of a VALUE statement, and you can reate an informat.

 

Glad you got it to work.

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore 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
  • 4 replies
  • 3575 views
  • 0 likes
  • 2 in conversation