How to rename the variables in a batch

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to rename the variables in a batch

albert_sun
Hi,

How to rename the variables in a data by add "_pre" for all of them in a syntax?

Reply | Threaded
Open this post in threaded view
|

Re: How to rename the variables in a batch

Jarrod Teo-2
Hi Xiaoxun,
 
As we know, SPSS command in variable label is
 
var lab xyz 'label'
abc 'label'.
 
So based on this, you might want to make use of Excel =concatenate to build the portion
 
xyz 'label'
abc 'label'
 
before placing it into SPSS. I just done the same thing to convert a text variable into 2000 over dummay variables yesterday for do repeat and it is done in 5 mins.
 
Warmest Regards
Jarrod Teo aka Dorraj Oet
 
> Date: Thu, 12 Sep 2013 17:10:03 -0700

> From: [hidden email]
> Subject: How to rename the variables in a batch
> To: [hidden email]
>
> Hi,
>
> How to rename the variables in a data by add "_pre" for all of them in a
> syntax?
>
>
>
>
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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
Reply | Threaded
Open this post in threaded view
|

Re: How to rename the variables in a batch

albert_sun
Thanks, Jarrod

I am thinking of using rename (x=y) this kind of thing rather than labels.




On Fri, Sep 13, 2013 at 10:19 AM, Jarrod Teo-2 [via SPSSX Discussion] <[hidden email]> wrote:
Hi Xiaoxun,
 
As we know, SPSS command in variable label is
 
var lab xyz 'label'
abc 'label'.
 
So based on this, you might want to make use of Excel =concatenate to build the portion
 
xyz 'label'
abc 'label'
 
before placing it into SPSS. I just done the same thing to convert a text variable into 2000 over dummay variables yesterday for do repeat and it is done in 5 mins.
 
Warmest Regards
Jarrod Teo aka Dorraj Oet
 
> Date: Thu, 12 Sep 2013 17:10:03 -0700

> From: [hidden email]

> Subject: How to rename the variables in a batch
> To: [hidden email]

>
> Hi,
>
> How to rename the variables in a data by add "_pre" for all of them in a
> syntax?
>
>
>
>
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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



If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946p5721947.html
To unsubscribe from How to rename the variables in a batch, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: How to rename the variables in a batch

Jarrod Teo-2
I see. Well, the same thing applies.
 
I suggest to build the code for the bolded area in excel using =concat.
 
rename var
(x=y)
(z=a).
 
I hope this helps.
 
Have a great day and a great weekend.
 
Warmest Regards
Jarrod Teo aka Dorraj Oet
 

Date: Thu, 12 Sep 2013 17:21:21 -0700
From: [hidden email]
Subject: Re: How to rename the variables in a batch
To: [hidden email]

Thanks, Jarrod

I am thinking of using rename (x=y) this kind of thing rather than labels.




On Fri, Sep 13, 2013 at 10:19 AM, Jarrod Teo-2 [via SPSSX Discussion] <[hidden email]> wrote:
Hi Xiaoxun,
 
As we know, SPSS command in variable label is
 
var lab xyz 'label'
abc 'label'.
 
So based on this, you might want to make use of Excel =concatenate to build the portion
 
xyz 'label'
abc 'label'
 
before placing it into SPSS. I just done the same thing to convert a text variable into 2000 over dummay variables yesterday for do repeat and it is done in 5 mins.
 
Warmest Regards
Jarrod Teo aka Dorraj Oet
 
> Date: Thu, 12 Sep 2013 17:10:03 -0700

> From: [hidden email]

> Subject: How to rename the variables in a batch
> To: [hidden email]

>
> Hi,
>
> How to rename the variables in a data by add "_pre" for all of them in a
> syntax?
>
>
>
>
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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



If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946p5721947.html
To unsubscribe from How to rename the variables in a batch, <a href="http://" rel="nofollow" target="_blank">click here.
NAML



View this message in context: Re: How to rename the variables in a batch
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to rename the variables in a batch

Jon K Peck
Trivial with Python.

begin program.
import spss
for v in range(spss.GetVariableCount()):
    vname = spss.GetVariableName(v)
    spss.Submit("""rename variables %s = %s.""" % (vname, vname + "_pre"))
end program.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Jarrod Teo <[hidden email]>
To:        [hidden email],
Date:        09/12/2013 06:27 PM
Subject:        Re: [SPSSX-L] How to rename the variables in a batch
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I see. Well, the same thing applies.

I suggest to build the code for the bolded area in excel using =concat.

rename var
(x=y)
(z=a).


I hope this helps.

Have a great day and a great weekend.

Warmest Regards
Jarrod Teo aka Dorraj Oet


Date: Thu, 12 Sep 2013 17:21:21 -0700
From: [hidden email]
Subject: Re: How to rename the variables in a batch
To: [hidden email]

Thanks, Jarrod

I am thinking of using rename (x=y) this kind of thing rather than labels.




On Fri, Sep 13, 2013 at 10:19 AM, Jarrod Teo-2 [via SPSSX Discussion] <[hidden email]> wrote:
Hi Xiaoxun,

As we know, SPSS command in variable label is

var lab xyz 'label'
abc 'label'.


So based on this, you might want to make use of Excel =concatenate to build the portion

xyz 'label'
abc 'label'

before placing it into SPSS. I just done the same thing to convert a text variable into 2000 over dummay variables yesterday for do repeat and it is done in 5 mins.

Warmest Regards
Jarrod Teo aka Dorraj Oet

> Date: Thu, 12 Sep 2013 17:10:03 -0700

> From:
[hidden email]

> Subject: How to rename the variables in a batch

> To: [hidden email]

>
> Hi,
>
> How to rename the variables in a data by add "_pre" for all of them in a
> syntax?
>
>
>
>
>
> --
> View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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





If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946p5721947.html
To unsubscribe from How to rename the variables in a batch, click here.
NAML



View this message in context: Re: How to rename the variables in a batch
Sent from the
SPSSX Discussion mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to rename the variables in a batch

albert_sun
Thanks, Jon

It works really well.




On Fri, Sep 13, 2013 at 10:44 AM, Jon K Peck [via SPSSX Discussion] <[hidden email]> wrote:
Trivial with Python.

begin program.
import spss
for v in range(spss.GetVariableCount()):
    vname = spss.GetVariableName(v)
    spss.Submit("""rename variables %s = %s.""" % (vname, vname + "_pre"))
end program.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: <a href="tel:720-342-5621" value="+17203425621" target="_blank">720-342-5621




From:        Jarrod Teo <[hidden email]>
To:        [hidden email],
Date:        09/12/2013 06:27 PM
Subject:        Re: [SPSSX-L] How to rename the variables in a batch
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I see. Well, the same thing applies.

I suggest to build the code for the bolded area in excel using =concat.

rename var
(x=y)
(z=a).


I hope this helps.

Have a great day and a great weekend.

Warmest Regards
Jarrod Teo aka Dorraj Oet


Date: Thu, 12 Sep 2013 17:21:21 -0700
From: [hidden email]

Subject: Re: How to rename the variables in a batch
To: [hidden email]

Thanks, Jarrod

I am thinking of using rename (x=y) this kind of thing rather than labels.




On Fri, Sep 13, 2013 at 10:19 AM, Jarrod Teo-2 [via SPSSX Discussion] <[hidden email]> wrote:
Hi Xiaoxun,

As we know, SPSS command in variable label is

var lab xyz 'label'
abc 'label'.


So based on this, you might want to make use of Excel =concatenate to build the portion

xyz 'label'
abc 'label'

before placing it into SPSS. I just done the same thing to convert a text variable into 2000 over dummay variables yesterday for do repeat and it is done in 5 mins.

Warmest Regards
Jarrod Teo aka Dorraj Oet

> Date: Thu, 12 Sep 2013 17:10:03 -0700

> From:
[hidden email]

> Subject: How to rename the variables in a batch

> To: [hidden email]

>
> Hi,
>
> How to rename the variables in a data by add "_pre" for all of them in a
> syntax?
>
>
>
>
>
> --
> View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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





If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946p5721947.html
To unsubscribe from How to rename the variables in a batch, click here.
NAML



View this message in context: Re: How to rename the variables in a batch
Sent from the
SPSSX Discussion mailing list archive at Nabble.com.



If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946p5721950.html
To unsubscribe from How to rename the variables in a batch, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: How to rename the variables in a batch

albert_sun
In reply to this post by Jon K Peck
One more thing, how to specify in Python if I want to exclude one variables (e.g., Y) in the rename?


On Fri, Sep 13, 2013 at 10:44 AM, Jon K Peck [via SPSSX Discussion] <[hidden email]> wrote:
Trivial with Python.

begin program.
import spss
for v in range(spss.GetVariableCount()):
    vname = spss.GetVariableName(v)
    spss.Submit("""rename variables %s = %s.""" % (vname, vname + "_pre"))
end program.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: <a href="tel:720-342-5621" value="+17203425621" target="_blank">720-342-5621




From:        Jarrod Teo <[hidden email]>
To:        [hidden email],
Date:        09/12/2013 06:27 PM
Subject:        Re: [SPSSX-L] How to rename the variables in a batch
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I see. Well, the same thing applies.

I suggest to build the code for the bolded area in excel using =concat.

rename var
(x=y)
(z=a).


I hope this helps.

Have a great day and a great weekend.

Warmest Regards
Jarrod Teo aka Dorraj Oet


Date: Thu, 12 Sep 2013 17:21:21 -0700
From: [hidden email]

Subject: Re: How to rename the variables in a batch
To: [hidden email]

Thanks, Jarrod

I am thinking of using rename (x=y) this kind of thing rather than labels.




On Fri, Sep 13, 2013 at 10:19 AM, Jarrod Teo-2 [via SPSSX Discussion] <[hidden email]> wrote:
Hi Xiaoxun,

As we know, SPSS command in variable label is

var lab xyz 'label'
abc 'label'.


So based on this, you might want to make use of Excel =concatenate to build the portion

xyz 'label'
abc 'label'

before placing it into SPSS. I just done the same thing to convert a text variable into 2000 over dummay variables yesterday for do repeat and it is done in 5 mins.

Warmest Regards
Jarrod Teo aka Dorraj Oet

> Date: Thu, 12 Sep 2013 17:10:03 -0700

> From:
[hidden email]

> Subject: How to rename the variables in a batch

> To: [hidden email]

>
> Hi,
>
> How to rename the variables in a data by add "_pre" for all of them in a
> syntax?
>
>
>
>
>
> --
> View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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





If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946p5721947.html
To unsubscribe from How to rename the variables in a batch, click here.
NAML



View this message in context: Re: How to rename the variables in a batch
Sent from the
SPSSX Discussion mailing list archive at Nabble.com.



If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946p5721950.html
To unsubscribe from How to rename the variables in a batch, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: How to rename the variables in a batch

Jon K Peck
begin program.
import spss
for v in range(spss.GetVariableCount()):
    vname = spss.GetVariableName(v)
    if not vname == "Y":
        spss.Submit("""rename variables %s = %s.""" % (vname, vname + "_pre"))
end program.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        albert_sun <[hidden email]>
To:        [hidden email],
Date:        09/12/2013 07:03 PM
Subject:        Re: [SPSSX-L] How to rename the variables in a batch
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




One more thing, how to specify in Python if I want to exclude one variables (e.g., Y) in the rename?


On Fri, Sep 13, 2013 at 10:44 AM, Jon K Peck [via SPSSX Discussion] <[hidden email]> wrote:
Trivial with Python.

begin program.

import spss

for v in range(spss.GetVariableCount()):

    vname = spss.GetVariableName(v)

    spss.Submit("""rename variables %s = %s.""" % (vname, vname + "_pre"))

end program.



Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM

[hidden email]
phone: <a href="tel:720-342-5621" value="+17203425621" target="_blank">720-342-5621





From:        
Jarrod Teo <[hidden email]>
To:        
[hidden email],
Date:        
09/12/2013 06:27 PM
Subject:        
Re: [SPSSX-L] How to rename the variables in a batch
Sent by:        
"SPSSX(r) Discussion" <[hidden email]>





I see. Well, the same thing applies.

I suggest to build the code for the bolded area in excel using =concat.

rename var
(x=y)
(z=a).


I hope this helps.

Have a great day and a great weekend.

Warmest Regards
Jarrod Teo aka Dorraj Oet




Date: Thu, 12 Sep 2013 17:21:21 -0700
From: [hidden email]

Subject: Re: How to rename the variables in a batch

To: [hidden email]

Thanks, Jarrod


I am thinking of using rename (x=y) this kind of thing rather than labels.




On Fri, Sep 13, 2013 at 10:19 AM, Jarrod Teo-2 [via SPSSX Discussion] <
[hidden email]> wrote:
Hi Xiaoxun,

As we know, SPSS command in variable label is

var lab xyz 'label'
abc 'label'.


So based on this, you might want to make use of Excel =concatenate to build the portion

xyz 'label'
abc 'label'

before placing it into SPSS. I just done the same thing to convert a text variable into 2000 over dummay variables yesterday for do repeat and it is done in 5 mins.

Warmest Regards
Jarrod Teo aka Dorraj Oet


> Date: Thu, 12 Sep 2013 17:10:03 -0700


> From:
[hidden email]

> Subject: How to rename the variables in a batch

> To:
[hidden email]

>
> Hi,
>
> How to rename the variables in a data by add "_pre" for all of them in a
> syntax?
>
>
>
>
>
> --
> View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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





If you reply to this email, your message will be added to the discussion below:

http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946p5721947.html
To unsubscribe from How to rename the variables in a batch,
click here.
NAML



View this message in context: Re: How to rename the variables in a batch
Sent from the
SPSSX Discussion mailing list archive at Nabble.com.




If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/How-to-rename-the-variables-in-a-batch-tp5721946p5721950.html
To unsubscribe from How to rename the variables in a batch, click here.
NAML



View this message in context: Re: How to rename the variables in a batch
Sent from the
SPSSX Discussion mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: How to rename the variables in a batch

Ruben Geert van den Berg
Or use this (http://www.pythonforspss.org/how-to-suffix-all-variable-names/). You can specify relevant variables efficiently using the "TO" and "ALL" keywords here in case you want to skip some variables.

HTH,

Ruben