At 10:31 AM 10/14/2009, Gene Maguin wrote:
I don't think you got what you
wanted in your test program. I just ran your syntax segment and checked
the data window. I think you intended the first six records to have 0, 1,
2, 3, 4, and 5 space characters, respectively. Those space characters
didn't show up in the data editor after running your data list/begin data
statements, which seems odd, actually.
SPSS string variables are fixed length. The number of trailing blanks is
the declared string length
(A(whatever))
minus the position of the last non-blank character in the
string.
There's a feature that can be confusing, indeed may be more confusing the
more carefully you think about it. SPSS string
values can have any
number of characters and can have, or not have, trailing blanks.
RTRIM(variable) need not be the same value
as
variable. Like the following. Notice that
I have to use COMPUTE, rather than reading data, to get values that
aren't fixed length.
NEW FILE.
INPUT PROGRAM.
. STRING SHORT(A8)
LONG1(A16)
LONG2(A16)
LONG3(A16).
. COMPUTE LONG1 = CONCAT("","X").
. COMPUTE SHORT = "".
. COMPUTE LONG2 = CONCAT(SHORT,"X").
. COMPUTE LONG3 = CONCAT(RTRIM(SHORT),"X").
. END CASE.
. COMPUTE LONG1 = CONCAT(" ","X").
. COMPUTE SHORT = " ".
. COMPUTE LONG2 = CONCAT(SHORT,"X").
. COMPUTE LONG3 = CONCAT(RTRIM(SHORT),"X").
. END CASE.
. COMPUTE LONG1 = CONCAT("
","X").
. COMPUTE SHORT = " ".
. COMPUTE LONG2 = CONCAT(SHORT,"X").
. COMPUTE LONG3 = CONCAT(RTRIM(SHORT),"X").
. END CASE.
END FILE.
END INPUT PROGRAM.
LIST.
|-----------------------------|---------------------------|
|Output
Created
|21-OCT-2009 13:31:33 |
|-----------------------------|---------------------------|
SHORT
LONG1
LONG2
LONG3
X
X X
X
X X
X
X X
Number of cases read: 3 Number of cases
listed: 3
=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD