On 11/13/2023 9:57 AM, charlie wrote: > Hi Heinz.. > > I can't figure this one either. > > I want the result to be in character string but the val puts it in numeric.
Read the description in help for the definition of the function. Val()
converts the numeric value in a string to a number. Val() is short for
"value".
> > Example > c = "10000" > ? transform(val(c), "@R 999,999") > This does come up with 10,000 but in numeric. > I tried this str(c) afterward but that doesn't work. > > Unless I am missing something.
The code above is not converting the value back to a string. It's just
outputting it.
c2 = transform(val(c), "@R 999,999")
Assigns the value to a new variable (so you aren't overwriting 'c'). If
you do this:
? c2
You should see that there is only a single leading space, if this were a
numeric value there would be more:
? 10000
This is a numeric value, you can tell among other things because of the
leading spaces in the output pane.