DATA Step, Macro, Functions and more

Syntax Error in Proc Format?

Reply
Super Contributor
Posts: 1,041

Syntax Error in Proc Format?

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

Super User
Posts: 5,516

Re: Syntax Error in Proc Format?

[ Edited ]
Posted in reply to robertrao

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.

Super Contributor
Posts: 1,041

Re: Syntax Error in Proc Format?

Posted in reply to Astounding

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.

 

Super Contributor
Posts: 1,041

Re: Syntax Error in Proc Format?

Posted in reply to Astounding

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

Super User
Posts: 5,516

Re: Syntax Error in Proc Format?

Posted in reply to robertrao

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.

Ask a Question
Discussion stats
  • 4 replies
  • 214 views
  • 0 likes
  • 2 in conversation