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

Hi,

This is a part of my format code and I am getting this error. Could you help me resolve it??

287  VALUE $SURGERIES

288  0-3="0-3"

289  4-7="4-7"

290  8-10="8-10"

ERROR: Start is greater than end: -.

291  11-13="11-13"

292  14-17="14-17"

293  18-20="18-20"

294  20-high=">=20"

295  other=" "

296  ;

1 ACCEPTED SOLUTION

Accepted Solutions
RichardinOz
Quartz | Level 8

Your value statement says you are defining a character format $SURGERIES.  Hence SAS is converting your numbers on the left to character values, ie 8-10="8-10" is being read as

     '8'-'10'="8-10"

and '8' > '10' because the comparison is on the first character.

If the data values you want to apply this format to are in fact numeric, then simply remove $ from the format name.

Otherwise you probably have leading blanks around numbers les than 10, so insert them in the values statement.

287  VALUE $SURGERIES

288  ' 0'-' 3'="0-3"

289  ' 4'-' 7'="4-7"

290  ' 8'-'10'="8-10"

291  '11'-'13'="11-13"

292  '14'-'17'="14-17"

293  '18'-'20'="18-20"

294  '21'-high=">=21"

295  other=" "

296  ;

View solution in original post

7 REPLIES 7
robertrao
Quartz | Level 8

287  VALUE $SURGERIES

288  0-3="0-3"

289  4-7="4-7"

290  8-10="8-10"

ERROR: Start is greater than end: -.

291  11-13="11-13"

292  14-17="14-17"

293  18-20="18-20"

294  21-high=">=21"

295  other=" "

296  ;

RichardinOz
Quartz | Level 8

Your value statement says you are defining a character format $SURGERIES.  Hence SAS is converting your numbers on the left to character values, ie 8-10="8-10" is being read as

     '8'-'10'="8-10"

and '8' > '10' because the comparison is on the first character.

If the data values you want to apply this format to are in fact numeric, then simply remove $ from the format name.

Otherwise you probably have leading blanks around numbers les than 10, so insert them in the values statement.

287  VALUE $SURGERIES

288  ' 0'-' 3'="0-3"

289  ' 4'-' 7'="4-7"

290  ' 8'-'10'="8-10"

291  '11'-'13'="11-13"

292  '14'-'17'="14-17"

293  '18'-'20'="18-20"

294  '21'-high=">=21"

295  other=" "

296  ;

robertrao
Quartz | Level 8

Perfect. I understood my mistake.

Could you tell me the meaning of:

and '8' > '10' because the comparison is on the first character.

RichardinOz
Quartz | Level 8

When SAS is comparing text strings, in this case '8' and '10', it compares the first character of each; if they are the same the next character is compared and so on.  In this case '8' is compared with '1' and in the character sort order '8' comes after '1' so it is regarded as greater than, hence '8' > '10'.  If there was a leading blank in the first string, the blank would be compared with the '1', giving the result ' 8' < '10'.

robertrao
Quartz | Level 8

Hi,

Thanks so much for your time

Regards

robertrao
Quartz | Level 8

Also I have another format like this:

To maintain the sort order I put 1 2 3 and 4 on the right side. Now in the output it looks confusing

it looks as if it is

1-<3

2-3-5

3-6-8

How can I maintain the order without putting those serial numbers????

VALUE CAP

0-2="1- <3"

3-5="2- 3-5"

6-8="3- 6-8"

9-high="4- >9"

other=" "

;

RUN;

Thanks

RichardinOz
Quartz | Level 8

If I understand you correctly you want the formatted values to sort properly for a report.

The problem is the '<' and '>' characters sort out of order.

This should work:

VALUE CAP

0-2="0 - 2"

3-5="3 - 5"

6-8="6 - 8"

9-high="9 +"

other=" "

;

Alternate suggestion for the 9-high range (increases the format width)

     9-high="9 or higher"

     9-high="More than 8"


or any phrase beginning with 9 or an alphanumeric

You could omit the other= line if there are no negative or missing values in your data. 

If there are missing values and you want null values to sort last

     other="NULL"

or

     other="N/A"


If you want invalid values to sort first but still have some formatted value I would suggest

     other="-"



SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 7262 views
  • 4 likes
  • 2 in conversation