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

Hello

What is wrong with the code below.

I am using proc format with negative values

 

29 low< -4000='Lower than -4K'
_
22
200
ERROR 22-322: Syntax error, expecting one of the following: (, ',', -, =.
ERROR 200-322: The symbol is not recognized and will be ignored.

 


proc format;
value ffmt    
low< -4000='Lower than -4K'
-4000-< -3000='[-4,-3)'
-3000-< -2000='[-3,-2)'
-2000-< -1000='[-2,-1)'
-1000-<- 0='[-1,0)'
0-< 1000='[0,1)'
1000-< 2000='[1,2)'
2000-< 3000='[2,3)'
3000-< 4000='[3,4)'
4000- high ='[4+'
;
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

This

 

low < -4000='Lower than -4K'

should be

 

low -< -4000='Lower than -4K'

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

A range needs the hyphen.

Do the following:

proc format;
value ffmt    
  low -< -4000 = 'Lower than -4K'
  -4000 -< -3000 = '[-4,-3)'
  -3000 -< -2000 = '[-3,-2)'
  -2000 -< -1000 = '[-2,-1)'
  -1000 -< 0 = '[-1,0)'
  0 -< 1000 = '[0,1)'
  1000 -< 2000 = '[1,2)'
  2000 -< 3000 = '[2,3)'
  3000 -< 4000 = '[3,4)'
  4000 - high = '[4+'
;
run;

Note that I added some visual formatting to make the code more readable.

Ronein
Onyx | Level 15

Okay,

I see that the error was

low < -4000

 

and the correct is

low-< -4000

 

What is the logic here?

 

proc format;
value ffmt    
low-< -4000='Lower than -4K'
-4000-< -3000='[-4,-3)'
-3000-< -2000='[-3,-2)'
-2000-< -1000='[-2,-1)'
-1000-<- 0='[-1,0)'
0-< 1000='[0,1)'
1000-< 2000='[1,2)'
2000-< 3000='[2,3)'
3000-< 4000='[3,4)'
4000- high ='[4+'
;
run;
PeterClemmensen
Tourmaline | Level 20

This

 

low < -4000='Lower than -4K'

should be

 

low -< -4000='Lower than -4K'

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 3 replies
  • 2382 views
  • 1 like
  • 3 in conversation