Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Insert A Variable Using Syntax

2,725 views
Skip to first unread message

Allen

unread,
Dec 18, 2009, 12:27:00 PM12/18/09
to
Does anyone know if its possible to insert a variable into an existing
data set using syntax and place it between two specified variables,
etc? Any response will be appreciated.

Thanks

Bruce Weaver

unread,
Dec 18, 2009, 1:28:02 PM12/18/09
to

Create the new variable in the usual fashion. E.g.,

STRING newstringvar (a8).
NUMERIC newnumericvar (f5.0).
compute newnumericvar2 = { some expression }.
exe.

Then re-order the variables using the /KEEP subcommand of either MATCH
FILES or ADD FILES. E.g., suppose you want to insert NEWVAR between
OLDVAR6 and OLDVAR7.

match files
file = * /
keep = oldvar1 to oldvar6 newvar oldvar7 all .
exe.

--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."

Ben Pfaff

unread,
Dec 18, 2009, 1:40:58 PM12/18/09
to
Bruce Weaver <bwe...@lakeheadu.ca> writes:

> Then re-order the variables using the /KEEP subcommand of either MATCH
> FILES or ADD FILES. E.g., suppose you want to insert NEWVAR between
> OLDVAR6 and OLDVAR7.
>
> match files
> file = * /
> keep = oldvar1 to oldvar6 newvar oldvar7 all .
> exe.

Some very old version of SPSS, or maybe it was SPSS/PC+, had a
MODIFY VARS command with a REORDER subcommand that was designed
just for reordering variables. I wonder why it didn't survive
over the years.
--
"The road to hell is paved with convenient shortcuts."
--Peter da Silva

0 new messages