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

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
Meteorite | Level 14

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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1628 views
  • 1 like
  • 3 in conversation