- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 ;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Perfect. I understood my mistake.
Could you tell me the meaning of:
and '8' > '10' because the comparison is on the first character.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks so much for your time
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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="-"