Date: Thu, 21 Sep 2006 05:21:21 -0700
Reply-To: Albert-jan Roskam <fomcl@yahoo.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Albert-jan Roskam <fomcl@yahoo.com>
Subject: Re: Moving varaibles using syntax
In-Reply-To: <820E5CA81E7A2544A9D7E0A25025E4813669C5@e2k0305.chestnut.net>
Content-Type: text/plain; charset=iso-8859-1
Hi,
The following code is based on Ray's method or
re-arranging a data set.
define alfabet (dir = !charend ('/') / oldnam =
!cmdend).
set mprint = on.
file handle inf/name= !dir + !oldnam.
get file=inf.
n of cases 1.
flip.
sort cases by case_lbl.
!let !oldnam2 = !unquote(!oldnam).
!let !newsps =
!quote(!concat('d:\temp\reorder--',!oldnam2,'.sps')).
do if $casenum=1.
write outfile=!newsps /"get file=inf/keep=".
end if.
write outfile=!newsps /" " case_lbl.
exe.
include file=!newsps.
exe.
variable alignment all (center).
save outfile = !dir +
!quote(!concat('reorder--',!oldnam2,'.sav')).
set mprint = off.
!enddefine.
** macro call(s).
** new sav file (with the prefix 'reorder--') is in
same dir.
** Syntax is saved in d:\temp.
!alfabet dir = "D:\temp\" / oldnam =
"youroldfilename.sav". /
Cheers!
Albert-Jan
--- Melissa Ives <mives@chestnut.org> wrote:
> Hello,
>
> I am assuming that by 'row #' you mean the row in
> the Variable View. I
> am also assuming that by requesting this in syntax,
> simply dragging the
> variable over to where you want it is not the
> solution you prefer.
>
>
> The way we usually reorder variables is with a save
> command that
> 'overwrites' the current dataset, then re-open it.
> E.g.
>
> SAVE OUTFILE='C:\myfile.sav'/keep=var1 to var14
> var16 to var35 var15
> var36 to varn.
> GET FILE='C:\myfile.sav'.
>
> You can drop in the list of variables using the
> variables icon if that
> is easier. You can also specify exactly the order
> of each individual
> variable or use the 'to' command to include multiple
> vars at once.
>
> Melissa
>
> -----Original Message-----
> From: SPSSX(r) Discussion
> [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
> Jignesh Sutar
> Sent: Wednesday, September 20, 2006 10:30 AM
> To: SPSSX-L@LISTSERV.UGA.EDU
> Subject: Re: [SPSSX-L] Moving varaibles using syntax
>
> Thanks,
>
> Still struggling to try find a solution to the exact
> problem...
>
> How does one move a variable which is in row 15
> initially to row 36??
> (by syntax)
>
>
>
> On 20/09/06, ariel barak <abarakabarak@gmail.com>
> wrote:
> >
> > Jignesh,
> >
> > I found how to do this myself two days ago after
> finding the topic
> > covered on Raynald's SPSS Tools site. Here is the
> syntax below...
> >
> > * How to delete or reorder variable names.
>
> * Raynald Levesque
> > 2002/02/09.
>
> DATA LIST LIST /id sex var1 z age.
> BEGIN DATA
> 1 1 1 1 25
> 2 2 2
> > 2 35
> 3 1 5 0 65
> END DATA.
>
> * TO change the order to the variables to age id
> > sex var1 z.
> MATCH FILES FILE=* /KEEP=age ALL.
> LIST.
>
> * NOTE: In the above
> > command, ALL means all remaining variables not
> previously named.
>
> * Use the
> > following to delete variables var1, z and age.
> MATCH FILES FILE=* /DROP=var1
> > z age.
> LIST.
> >
> >
> >
> > On 9/20/06, Jignesh Sutar <jignesh.sutar@gmail.com
> > wrote:
> > > Hello,
> > >
> > > Is it possible to move variable position using
> syntax? Using SPSS
> > > v15
> > >
> > > Thanks in advance
> > > Jignesh
> > >
> >
> >
>
>
>
> PRIVILEGED AND CONFIDENTIAL INFORMATION
> This transmittal and any attachments may contain
> PRIVILEGED AND
> CONFIDENTIAL information and is intended only for
> the use of the
> addressee. If you are not the designated recipient,
> or an employee
> or agent authorized to deliver such transmittals to
> the designated
> recipient, you are hereby notified that any
> dissemination,
> copying or publication of this transmittal is
> strictly prohibited. If
> you have received this transmittal in error, please
> notify us
> immediately by replying to the sender and delete
> this copy from your
> system. You may also call us at (309) 827-6026 for
> assistance.
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|