For the first time in the SAS System, an informat TRAILSGN has been introduced to read numeric values where the sign follows the value.
http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a002637855.htm
A quick test shows that this informat also supports a leading sign, to see the results of both leading and trailing minus signs among other variations, please see log below:
| 215 |
data tryIt; |
| 216 |
infile datalines truncover ; |
| 217 |
informat result trailSgn. ; |
| 218 |
input result @1 value $char50. ; |
| 219 |
put result= @20 value= ; |
| 220 |
datalines; |
| result = 1234 |
value = 1234 |
Without any signs |
| result = -1234 |
value = 1234- |
Supported trailing negative sign |
| result = -12345 |
value = 12345.- |
Supported after . |
| result = -123450 |
value = 12345e1- |
Supported after float |
| result = -1234.5 |
value = 12345e-1- |
Supported after negative float |
| result = 1234 |
value = 1234 - |
Sign after a blank character |
| result = -123 |
value = -123 |
Supported leading negative sign |
| result = 12345 |
value = -12345- |
With both trailing and leading signs |
| result = 1234 |
value = 1234+ |
Supported trailing positive sign |
| result = 1234 |
value = +1234 |
Supported leading positive sign |
| 232 |
data tryAgain ; |
| 233 |
infile datalines truncover ; |
| 234 |
input result trailSgn7. @1 value $char50. ; |
| 235 |
put result= @20 value= ; |
| 236 |
datalines; |
| result = 1234567 |
value = 1234567 |
Width |
| result = -1234 |
value = 1234 - |
Sign within informat width |
| result = 12.345 |
value = 12.345 - |
Sign outside informat width |