Help Adding a prefix/suffix to a list of existing variable names

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

Help Adding a prefix/suffix to a list of existing variable names

James Feely
Good morning, I have hit a wall in a current project. I am trying to take a list of existing variable names: NHitMonthsago..00 NHitMonthsago.1.00 NHitMonthsago.2.00 NHitMonthsago.3.00 NHitMonthsago.4.00 NHitMonthsago.5.00 NHitMonthsago.6.00 NHitMonthsago.7.00 NHitMonthsago.8.00 NHitMonthsago.9.00 NHitMonthsago.10.00 NHitMonthsago.11.00 NHitMonthsago.12.00 And I would like to add a prefix/suffix to each of the above variable names from values that exist as data in a different variable (I could also store these new values in a set of scratch variables if that is easier). Example Variable “Month1 = May” and I would like to add the “May” value as a prefix to the existing variable name “NHitMonthsago.1.00” with a the existing variable having its new name be “May_ NHitMonthsago.1.00”. The value stored in the Month1 variable will change to indicate the current starting month. I have a unique matching variable for each months possiblity. Month0 Month1 Month2 Month3 Month4 Month5 Month6 Month7 Month8 Month9 Month10 Month11 I thought to use a variation of the Macro below, but I can’t quite get how to use a second list of variable data instead of the fixed value “_Suffix” Thank you for any help James Feely Project Manager Data and Analytics. define !rename2 (vlist = !charend('/') /suffix=!cmdend ) !do !vname !in (!vlist) !let !nname = !concat(!vname, !suffix) rename variables (!vname = !nname). !doend !enddefine. !rename2 vlist = NHitMonthsago..00 NHitMonthsago.1.00 NHitMonthsago.2.00 NHitMonthsago.3.00 NHitMonthsago.4.00 NHitMonthsago.5.00 NHitMonthsago.6.00 NHitMonthsago.7.00 NHitMonthsago.8.00 NHitMonthsago.9.00 NHitMonthsago.10.00 NHitMonthsago.11.00 NHitMonthsago.12.00 NHitMonthsago.13.00 NHitMonthsago.14.00 NHitMonthsago.15.00 NHitMonthsago.16.00 NHitMonthsago.17.00 NHitMonthsago.18.00 NHitMonthsago.19.00 NHitMonthsago.20.00 NHitMonthsago.21.00 NHitMonthsago.22.00 NHitMonthsago.23.00 NHitMonthsago.24.00 NHitMonthsago.25.00 /suffix = _Suffix . ===================== 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
|

Help Adding a prefix/suffix to a list of existing variable names

James Feely

Good morning,

 

I have hit a wall in a current project.

 

I am trying to take a list of existing variable names:

 

NHitMonthsago..00

NHitMonthsago.1.00

NHitMonthsago.2.00

NHitMonthsago.3.00

NHitMonthsago.4.00

NHitMonthsago.5.00

NHitMonthsago.6.00

NHitMonthsago.7.00

NHitMonthsago.8.00

NHitMonthsago.9.00

NHitMonthsago.10.00

NHitMonthsago.11.00

NHitMonthsago.12.00

 

 

And I would like to add a prefix/suffix to each of the above variable names from values that exist as data in a different variable (I could also store these new values in a set of scratch variables if that is easier).

 

Example Variable “Month1 = May” and I would like to add the “May” value as a prefix to the existing variable name “NHitMonthsago.1.00” with a the existing variable having its new name be “May_ NHitMonthsago.1.00”.

 

The value stored in the Month1 variable will change to indicate the current starting month. I have a unique matching variable for each months possiblity.

 

Month0

Month1

Month2

Month3

Month4

Month5

Month6

Month7

Month8

Month9

Month10

Month11

 

I thought to use a variation of the Macro below, but I can’t quite get how to use a second list of variable data instead of the fixed value “_Suffix”

 

Thank you for any help

 

James Feely

Project Manager Data and Analytics.

 

define !rename2 (vlist = !charend('/')

                        /suffix=!cmdend )

 

!do !vname !in (!vlist)

!let !nname = !concat(!vname, !suffix)

rename variables (!vname = !nname).

!doend

!enddefine.

 

!rename2 vlist =

NHitMonthsago..00

NHitMonthsago.1.00

NHitMonthsago.2.00

NHitMonthsago.3.00

NHitMonthsago.4.00

NHitMonthsago.5.00

NHitMonthsago.6.00

NHitMonthsago.7.00

NHitMonthsago.8.00

NHitMonthsago.9.00

NHitMonthsago.10.00

NHitMonthsago.11.00

NHitMonthsago.12.00

NHitMonthsago.13.00

NHitMonthsago.14.00

NHitMonthsago.15.00

NHitMonthsago.16.00

NHitMonthsago.17.00

NHitMonthsago.18.00

NHitMonthsago.19.00

NHitMonthsago.20.00

NHitMonthsago.21.00

NHitMonthsago.22.00

NHitMonthsago.23.00

NHitMonthsago.24.00

NHitMonthsago.25.00

              /suffix = _Suffix .

 

 

===================== 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: Help Adding a prefix/suffix to a list of existing variable names

Bruce Weaver
Administrator
In reply to this post by James Feely
Yikes!  Your post all ran together in the Nabble archive.  I think it is a lot more readable in the quoted section below.  Anyway, I think you need to use a trick David Marso showed me once upon a time to process in parallel two lists of macro arguments.  See if the following (untested) works for you.


DEFINE !rename3
 (vlist = !charend('/') /
  slist=!cmdend )

!LET !VCOPY=!vlist
**PARALLEL PROCESS VARIABLE LISTS **
!DO !suffix !IN (!slist) !LET !V = !HEAD(!VCOPY) !LET !VCOPY=!TAIL(!VCOPY)

!do !vname !in (!vlist)
!let !nname = !concat(!vname, !suffix)
rename variables (!vname = !nname).
!DOEND
!ENDDEFINE.


James Feely wrote
Good morning,

I have hit a wall in a current project.

I am trying to take a list of existing variable names:

NHitMonthsago..00
NHitMonthsago.1.00
NHitMonthsago.2.00
NHitMonthsago.3.00
NHitMonthsago.4.00
NHitMonthsago.5.00
NHitMonthsago.6.00
NHitMonthsago.7.00
NHitMonthsago.8.00
NHitMonthsago.9.00
NHitMonthsago.10.00
NHitMonthsago.11.00
NHitMonthsago.12.00


And I would like to add a prefix/suffix to each of the above variable names from values that exist as data in a different variable (I could also store these new values in a set of scratch variables if that is easier).

Example Variable “Month1 = May” and I would like to add the “May” value as a prefix to the existing variable name “NHitMonthsago.1.00” with a the existing variable having its new name be “May_ NHitMonthsago.1.00”.

The value stored in the Month1 variable will change to indicate the current starting month. I have a unique matching variable for each months possiblity.

Month0
Month1
Month2
Month3
Month4
Month5
Month6
Month7
Month8
Month9
Month10
Month11

I thought to use a variation of the Macro below, but I can’t quite get how to use a second list of variable data instead of the fixed value “_Suffix”

Thank you for any help

James Feely
Project Manager Data and Analytics.

define !rename2 (vlist = !charend('/')
                        /suffix=!cmdend )

!do !vname !in (!vlist)
!let !nname = !concat(!vname, !suffix)
rename variables (!vname = !nname).
!doend
!enddefine.

!rename2 vlist =
NHitMonthsago..00
NHitMonthsago.1.00
NHitMonthsago.2.00
NHitMonthsago.3.00
NHitMonthsago.4.00
NHitMonthsago.5.00
NHitMonthsago.6.00
NHitMonthsago.7.00
NHitMonthsago.8.00
NHitMonthsago.9.00
NHitMonthsago.10.00
NHitMonthsago.11.00
NHitMonthsago.12.00
NHitMonthsago.13.00
NHitMonthsago.14.00
NHitMonthsago.15.00
NHitMonthsago.16.00
NHitMonthsago.17.00
NHitMonthsago.18.00
NHitMonthsago.19.00
NHitMonthsago.20.00
NHitMonthsago.21.00
NHitMonthsago.22.00
NHitMonthsago.23.00
NHitMonthsago.24.00
NHitMonthsago.25.00
              /suffix = _Suffix .


=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Help Adding a prefix/suffix to a list of existing variable names

James Feely
Hi Bruce,

Sorry about the post being ran together (first posting). This looks like it solves another issue I have, but I am not sure it is exactly what I am looking for.

The second set of information needs to be read from a variable in the data set, not a predefined list in the macro/syntax. Am I missing something?

Thanks for any additional help. (You are right, this is a neat trick :))

James Feely

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver
Sent: Monday, June 01, 2015 2:11 PM
To: [hidden email]
Subject: Re: Help Adding a prefix/suffix to a list of existing variable names

Yikes!  Your post all ran together in the Nabble archive.  I think it is a lot more readable in the quoted section below.  Anyway, I think you need to use a trick David Marso showed me once upon a time to process in parallel two lists of macro arguments.  See if the following (untested) works for you.


DEFINE !rename3
 (vlist = !charend('/') /
  slist=!cmdend )

!LET !VCOPY=!vlist
**PARALLEL PROCESS VARIABLE LISTS **
!DO !suffix !IN (!slist) !LET !V = !HEAD(!VCOPY) !LET !VCOPY=!TAIL(!VCOPY)

!do !vname !in (!vlist)
!let !nname = !concat(!vname, !suffix)
rename variables (!vname = !nname).
!DOEND
!ENDDEFINE.



James Feely wrote

> Good morning,
>
> I have hit a wall in a current project.
>
> I am trying to take a list of existing variable names:
>
> NHitMonthsago..00
> NHitMonthsago.1.00
> NHitMonthsago.2.00
> NHitMonthsago.3.00
> NHitMonthsago.4.00
> NHitMonthsago.5.00
> NHitMonthsago.6.00
> NHitMonthsago.7.00
> NHitMonthsago.8.00
> NHitMonthsago.9.00
> NHitMonthsago.10.00
> NHitMonthsago.11.00
> NHitMonthsago.12.00
>
>
> And I would like to add a prefix/suffix to each of the above variable
> names from values that exist as data in a different variable (I could also
> store these new values in a set of scratch variables if that is easier).
>
> Example Variable “Month1 = May” and I would like to add the “May” value as
> a prefix to the existing variable name “NHitMonthsago.1.00” with a the
> existing variable having its new name be “May_ NHitMonthsago.1.00”.
>
> The value stored in the Month1 variable will change to indicate the
> current starting month. I have a unique matching variable for each months
> possiblity.
>
> Month0
> Month1
> Month2
> Month3
> Month4
> Month5
> Month6
> Month7
> Month8
> Month9
> Month10
> Month11
>
> I thought to use a variation of the Macro below, but I can’t quite get how
> to use a second list of variable data instead of the fixed value “_Suffix”
>
> Thank you for any help
>
> James Feely
> Project Manager Data and Analytics.
>
> define !rename2 (vlist = !charend('/')
>                         /suffix=!cmdend )
>
> !do !vname !in (!vlist)
> !let !nname = !concat(!vname, !suffix)
> rename variables (!vname = !nname).
> !doend
> !enddefine.
>
> !rename2 vlist =
> NHitMonthsago..00
> NHitMonthsago.1.00
> NHitMonthsago.2.00
> NHitMonthsago.3.00
> NHitMonthsago.4.00
> NHitMonthsago.5.00
> NHitMonthsago.6.00
> NHitMonthsago.7.00
> NHitMonthsago.8.00
> NHitMonthsago.9.00
> NHitMonthsago.10.00
> NHitMonthsago.11.00
> NHitMonthsago.12.00
> NHitMonthsago.13.00
> NHitMonthsago.14.00
> NHitMonthsago.15.00
> NHitMonthsago.16.00
> NHitMonthsago.17.00
> NHitMonthsago.18.00
> NHitMonthsago.19.00
> NHitMonthsago.20.00
> NHitMonthsago.21.00
> NHitMonthsago.22.00
> NHitMonthsago.23.00
> NHitMonthsago.24.00
> NHitMonthsago.25.00
>               /suffix = _Suffix .
>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Help-Adding-a-prefix-suffix-to-a-list-of-existing-variable-names-tp5729685p5729690.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

=====================
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: Help Adding a prefix/suffix to a list of existing variable names

Jon K Peck
Macros cannot refer to case data in any reasonable way while Python can easily do this (as well as all the renaming).  What isn't clear to me is how the data are being used in this process.  Are these constant variables? In the same dataset or another one, or even read from a text file.


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




From:        James Feely <[hidden email]>
To:        [hidden email]
Date:        06/01/2015 03:22 PM
Subject:        Re: [SPSSX-L] Help Adding a prefix/suffix to a list of existing variable names
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hi Bruce,

Sorry about the post being ran together (first posting). This looks like it solves another issue I have, but I am not sure it is exactly what I am looking for.

The second set of information needs to be read from a variable in the data set, not a predefined list in the macro/syntax. Am I missing something?

Thanks for any additional help. (You are right, this is a neat trick :))

James Feely

-----Original Message-----
From: SPSSX(r) Discussion [
[hidden email]] On Behalf Of Bruce Weaver
Sent: Monday, June 01, 2015 2:11 PM
To: [hidden email]
Subject: Re: Help Adding a prefix/suffix to a list of existing variable names

Yikes!  Your post all ran together in the Nabble archive.  I think it is a lot more readable in the quoted section below.  Anyway, I think you need to use a trick David Marso showed me once upon a time to process in parallel two lists of macro arguments.  See if the following (untested) works for you.


DEFINE !rename3
(vlist = !charend('/') /
 slist=!cmdend )

!LET !VCOPY=!vlist
**PARALLEL PROCESS VARIABLE LISTS **
!DO !suffix !IN (!slist) !LET !V = !HEAD(!VCOPY) !LET !VCOPY=!TAIL(!VCOPY)

!do !vname !in (!vlist)
!let !nname = !concat(!vname, !suffix)
rename variables (!vname = !nname).
!DOEND
!ENDDEFINE.



James Feely wrote
> Good morning,
>
> I have hit a wall in a current project.
>
> I am trying to take a list of existing variable names:
>
> NHitMonthsago..00
> NHitMonthsago.1.00
> NHitMonthsago.2.00
> NHitMonthsago.3.00
> NHitMonthsago.4.00
> NHitMonthsago.5.00
> NHitMonthsago.6.00
> NHitMonthsago.7.00
> NHitMonthsago.8.00
> NHitMonthsago.9.00
> NHitMonthsago.10.00
> NHitMonthsago.11.00
> NHitMonthsago.12.00
>
>
> And I would like to add a prefix/suffix to each of the above variable
> names from values that exist as data in a different variable (I could also
> store these new values in a set of scratch variables if that is easier).
>
> Example Variable “Month1 = May” and I would like to add the “May” value as
> a prefix to the existing variable name “NHitMonthsago.1.00” with a the
> existing variable having its new name be “May_ NHitMonthsago.1.00”.
>
> The value stored in the Month1 variable will change to indicate the
> current starting month. I have a unique matching variable for each months
> possiblity.
>
> Month0
> Month1
> Month2
> Month3
> Month4
> Month5
> Month6
> Month7
> Month8
> Month9
> Month10
> Month11
>
> I thought to use a variation of the Macro below, but I can’t quite get how
> to use a second list of variable data instead of the fixed value “_Suffix”
>
> Thank you for any help
>
> James Feely
> Project Manager Data and Analytics.
>
> define !rename2 (vlist = !charend('/')
>                         /suffix=!cmdend )
>
> !do !vname !in (!vlist)
> !let !nname = !concat(!vname, !suffix)
> rename variables (!vname = !nname).
> !doend
> !enddefine.
>
> !rename2 vlist =
> NHitMonthsago..00
> NHitMonthsago.1.00
> NHitMonthsago.2.00
> NHitMonthsago.3.00
> NHitMonthsago.4.00
> NHitMonthsago.5.00
> NHitMonthsago.6.00
> NHitMonthsago.7.00
> NHitMonthsago.8.00
> NHitMonthsago.9.00
> NHitMonthsago.10.00
> NHitMonthsago.11.00
> NHitMonthsago.12.00
> NHitMonthsago.13.00
> NHitMonthsago.14.00
> NHitMonthsago.15.00
> NHitMonthsago.16.00
> NHitMonthsago.17.00
> NHitMonthsago.18.00
> NHitMonthsago.19.00
> NHitMonthsago.20.00
> NHitMonthsago.21.00
> NHitMonthsago.22.00
> NHitMonthsago.23.00
> NHitMonthsago.24.00
> NHitMonthsago.25.00
>               /suffix = _Suffix .
>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Help-Adding-a-prefix-suffix-to-a-list-of-existing-variable-names-tp5729685p5729690.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

=====================
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

===================== 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: Help Adding a prefix/suffix to a list of existing variable names

Bruce Weaver
Administrator
In reply to this post by James Feely
Hello James.  Okay, I'll bite.  How is that going to work?  I think what you are saying is you want to rename variables as follows

 NHitMonthsago..00  becomes  NHitMonthsago..00_suffix0
 NHitMonthsago.1.00 becomes NHitMonthsago.1.00_suffix1
 NHitMonthsago.2.00 becomes NHitMonthsago.2.00_suffix2
 etc .

where suffix0, suffix1 and suffix2 (etc) are the VALUES of some other variable, or maybe multiple variables.  But those other variables could have have multiple values (perhaps even a different value on every case in the file).  Which one of those multiple possible values do you want to use?

Even if there is only one possible value per variable, you'll still have to figure out how to rename the variables only once (e.g., when $casenum EQ 1) rather than once per every case in the data file.

Perhaps my confusion about what you want to do will prompt someone else to jump in here and sort it all out!  ;-)



James Feely wrote
Hi Bruce,

Sorry about the post being ran together (first posting). This looks like it solves another issue I have, but I am not sure it is exactly what I am looking for.

The second set of information needs to be read from a variable in the data set, not a predefined list in the macro/syntax. Am I missing something?

Thanks for any additional help. (You are right, this is a neat trick :))

James Feely

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver
Sent: Monday, June 01, 2015 2:11 PM
To: [hidden email]
Subject: Re: Help Adding a prefix/suffix to a list of existing variable names

Yikes!  Your post all ran together in the Nabble archive.  I think it is a lot more readable in the quoted section below.  Anyway, I think you need to use a trick David Marso showed me once upon a time to process in parallel two lists of macro arguments.  See if the following (untested) works for you.


DEFINE !rename3
 (vlist = !charend('/') /
  slist=!cmdend )

!LET !VCOPY=!vlist
**PARALLEL PROCESS VARIABLE LISTS **
!DO !suffix !IN (!slist) !LET !V = !HEAD(!VCOPY) !LET !VCOPY=!TAIL(!VCOPY)

!do !vname !in (!vlist)
!let !nname = !concat(!vname, !suffix)
rename variables (!vname = !nname).
!DOEND
!ENDDEFINE.



James Feely wrote
> Good morning,
>
> I have hit a wall in a current project.
>
> I am trying to take a list of existing variable names:
>
> NHitMonthsago..00
> NHitMonthsago.1.00
> NHitMonthsago.2.00
> NHitMonthsago.3.00
> NHitMonthsago.4.00
> NHitMonthsago.5.00
> NHitMonthsago.6.00
> NHitMonthsago.7.00
> NHitMonthsago.8.00
> NHitMonthsago.9.00
> NHitMonthsago.10.00
> NHitMonthsago.11.00
> NHitMonthsago.12.00
>
>
> And I would like to add a prefix/suffix to each of the above variable
> names from values that exist as data in a different variable (I could also
> store these new values in a set of scratch variables if that is easier).
>
> Example Variable “Month1 = May” and I would like to add the “May” value as
> a prefix to the existing variable name “NHitMonthsago.1.00” with a the
> existing variable having its new name be “May_ NHitMonthsago.1.00”.
>
> The value stored in the Month1 variable will change to indicate the
> current starting month. I have a unique matching variable for each months
> possiblity.
>
> Month0
> Month1
> Month2
> Month3
> Month4
> Month5
> Month6
> Month7
> Month8
> Month9
> Month10
> Month11
>
> I thought to use a variation of the Macro below, but I can’t quite get how
> to use a second list of variable data instead of the fixed value “_Suffix”
>
> Thank you for any help
>
> James Feely
> Project Manager Data and Analytics.
>
> define !rename2 (vlist = !charend('/')
>                         /suffix=!cmdend )
>
> !do !vname !in (!vlist)
> !let !nname = !concat(!vname, !suffix)
> rename variables (!vname = !nname).
> !doend
> !enddefine.
>
> !rename2 vlist =
> NHitMonthsago..00
> NHitMonthsago.1.00
> NHitMonthsago.2.00
> NHitMonthsago.3.00
> NHitMonthsago.4.00
> NHitMonthsago.5.00
> NHitMonthsago.6.00
> NHitMonthsago.7.00
> NHitMonthsago.8.00
> NHitMonthsago.9.00
> NHitMonthsago.10.00
> NHitMonthsago.11.00
> NHitMonthsago.12.00
> NHitMonthsago.13.00
> NHitMonthsago.14.00
> NHitMonthsago.15.00
> NHitMonthsago.16.00
> NHitMonthsago.17.00
> NHitMonthsago.18.00
> NHitMonthsago.19.00
> NHitMonthsago.20.00
> NHitMonthsago.21.00
> NHitMonthsago.22.00
> NHitMonthsago.23.00
> NHitMonthsago.24.00
> NHitMonthsago.25.00
>               /suffix = _Suffix .
>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Help-Adding-a-prefix-suffix-to-a-list-of-existing-variable-names-tp5729685p5729690.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

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Help Adding a prefix/suffix to a list of existing variable names

David Marso
Administrator
I have precisely the same concerns as Bruce & Jon regarding this topic.
Perhaps James would like to clarify.
Maybe 'horrible hack' time or python?
--
Bruce Weaver wrote
Hello James.  Okay, I'll bite.  How is that going to work?  I think what you are saying is you want to rename variables as follows

 NHitMonthsago..00  becomes  NHitMonthsago..00_suffix0
 NHitMonthsago.1.00 becomes NHitMonthsago.1.00_suffix1
 NHitMonthsago.2.00 becomes NHitMonthsago.2.00_suffix2
 etc .

where suffix0, suffix1 and suffix2 (etc) are the VALUES of some other variable, or maybe multiple variables.  But those other variables could have have multiple values (perhaps even a different value on every case in the file).  Which one of those multiple possible values do you want to use?

Even if there is only one possible value per variable, you'll still have to figure out how to rename the variables only once (e.g., when $casenum EQ 1) rather than once per every case in the data file.

Perhaps my confusion about what you want to do will prompt someone else to jump in here and sort it all out!  ;-)



James Feely wrote
Hi Bruce,

Sorry about the post being ran together (first posting). This looks like it solves another issue I have, but I am not sure it is exactly what I am looking for.

The second set of information needs to be read from a variable in the data set, not a predefined list in the macro/syntax. Am I missing something?

Thanks for any additional help. (You are right, this is a neat trick :))

James Feely

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver
Sent: Monday, June 01, 2015 2:11 PM
To: [hidden email]
Subject: Re: Help Adding a prefix/suffix to a list of existing variable names

Yikes!  Your post all ran together in the Nabble archive.  I think it is a lot more readable in the quoted section below.  Anyway, I think you need to use a trick David Marso showed me once upon a time to process in parallel two lists of macro arguments.  See if the following (untested) works for you.


DEFINE !rename3
 (vlist = !charend('/') /
  slist=!cmdend )

!LET !VCOPY=!vlist
**PARALLEL PROCESS VARIABLE LISTS **
!DO !suffix !IN (!slist) !LET !V = !HEAD(!VCOPY) !LET !VCOPY=!TAIL(!VCOPY)

!do !vname !in (!vlist)
!let !nname = !concat(!vname, !suffix)
rename variables (!vname = !nname).
!DOEND
!ENDDEFINE.



James Feely wrote
> Good morning,
>
> I have hit a wall in a current project.
>
> I am trying to take a list of existing variable names:
>
> NHitMonthsago..00
> NHitMonthsago.1.00
> NHitMonthsago.2.00
> NHitMonthsago.3.00
> NHitMonthsago.4.00
> NHitMonthsago.5.00
> NHitMonthsago.6.00
> NHitMonthsago.7.00
> NHitMonthsago.8.00
> NHitMonthsago.9.00
> NHitMonthsago.10.00
> NHitMonthsago.11.00
> NHitMonthsago.12.00
>
>
> And I would like to add a prefix/suffix to each of the above variable
> names from values that exist as data in a different variable (I could also
> store these new values in a set of scratch variables if that is easier).
>
> Example Variable “Month1 = May” and I would like to add the “May” value as
> a prefix to the existing variable name “NHitMonthsago.1.00” with a the
> existing variable having its new name be “May_ NHitMonthsago.1.00”.
>
> The value stored in the Month1 variable will change to indicate the
> current starting month. I have a unique matching variable for each months
> possiblity.
>
> Month0
> Month1
> Month2
> Month3
> Month4
> Month5
> Month6
> Month7
> Month8
> Month9
> Month10
> Month11
>
> I thought to use a variation of the Macro below, but I can’t quite get how
> to use a second list of variable data instead of the fixed value “_Suffix”
>
> Thank you for any help
>
> James Feely
> Project Manager Data and Analytics.
>
> define !rename2 (vlist = !charend('/')
>                         /suffix=!cmdend )
>
> !do !vname !in (!vlist)
> !let !nname = !concat(!vname, !suffix)
> rename variables (!vname = !nname).
> !doend
> !enddefine.
>
> !rename2 vlist =
> NHitMonthsago..00
> NHitMonthsago.1.00
> NHitMonthsago.2.00
> NHitMonthsago.3.00
> NHitMonthsago.4.00
> NHitMonthsago.5.00
> NHitMonthsago.6.00
> NHitMonthsago.7.00
> NHitMonthsago.8.00
> NHitMonthsago.9.00
> NHitMonthsago.10.00
> NHitMonthsago.11.00
> NHitMonthsago.12.00
> NHitMonthsago.13.00
> NHitMonthsago.14.00
> NHitMonthsago.15.00
> NHitMonthsago.16.00
> NHitMonthsago.17.00
> NHitMonthsago.18.00
> NHitMonthsago.19.00
> NHitMonthsago.20.00
> NHitMonthsago.21.00
> NHitMonthsago.22.00
> NHitMonthsago.23.00
> NHitMonthsago.24.00
> NHitMonthsago.25.00
>               /suffix = _Suffix .
>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Help-Adding-a-prefix-suffix-to-a-list-of-existing-variable-names-tp5729685p5729690.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

=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Help Adding a prefix/suffix to a list of existing variable names

James Feely
In reply to this post by Bruce Weaver
Hi Bruce exactly,

This syntax get runs run monthly and includes data about web content usage, The variables that I want to change contains information for the past twelve months, I am dumping this out for another user. I am trying to avoid them having to figure out that NHitMonthago.2.00 is the equivalent of April this month and next month it will be May and so on. So I compute what each of the past twelve months are and I can store those values as variable data and then will delete those variables when I don't need them any longer. The value in each variable is the same for every case. It’s a little brute force but it works.

The problem is getting that data from a value in the dataset (or scratch variable) to a suffix attached to a rename of the existing NHitMonthagao.2.00 variable.

I think this can be done in Python, but right now we are having some issue with Python.

I hope this helps clarify what I am trying to accomplish.

Thanks
James

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver
Sent: Monday, June 01, 2015 2:48 PM
To: [hidden email]
Subject: Re: Help Adding a prefix/suffix to a list of existing variable names

Hello James.  Okay, I'll bite.  How is that going to work?  I think what you are saying is you want to rename variables as follows

 NHitMonthsago..00  becomes  NHitMonthsago..00_suffix0
 NHitMonthsago.1.00 becomes NHitMonthsago.1.00_suffix1
 NHitMonthsago.2.00 becomes NHitMonthsago.2.00_suffix2  etc .

where suffix0, suffix1 and suffix2 (etc) are the VALUES of some other variable, or maybe multiple variables.  But those other variables could have have multiple values (perhaps even a different value on every case in the file).  Which one of those multiple possible values do you want to use?

Even if there is only one possible value per variable, you'll still have to figure out how to rename the variables only once (e.g., when $casenum EQ 1) rather than once per every case in the data file.

Perhaps my confusion about what you want to do will prompt someone else to jump in here and sort it all out!  ;-)




James Feely wrote

> Hi Bruce,
>
> Sorry about the post being ran together (first posting). This looks
> like it solves another issue I have, but I am not sure it is exactly
> what I am looking for.
>
> The second set of information needs to be read from a variable in the
> data set, not a predefined list in the macro/syntax. Am I missing something?
>
> Thanks for any additional help. (You are right, this is a neat trick
> :))
>
> James Feely
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:

> SPSSX-L@.UGA

> ] On Behalf Of Bruce Weaver
> Sent: Monday, June 01, 2015 2:11 PM
> To:

> SPSSX-L@.UGA

> Subject: Re: Help Adding a prefix/suffix to a list of existing
> variable names
>
> Yikes!  Your post all ran together in the Nabble archive.  I think it
> is a lot more readable in the quoted section below.  Anyway, I think
> you need to use a trick David Marso showed me once upon a time to
> process in parallel two lists of macro arguments.  See if the
> following (untested) works for you.
>
>
> DEFINE !rename3
>  (vlist = !charend('/') /
>   slist=!cmdend )
>
> !LET !VCOPY=!vlist
> **PARALLEL PROCESS VARIABLE LISTS **
> !DO !suffix !IN (!slist) !LET !V = !HEAD(!VCOPY) !LET
> !VCOPY=!TAIL(!VCOPY)
>
> !do !vname !in (!vlist)
> !let !nname = !concat(!vname, !suffix) rename variables (!vname =
> !nname).
> !DOEND
> !ENDDEFINE.
>
>
>
> James Feely wrote
>> Good morning,
>>
>> I have hit a wall in a current project.
>>
>> I am trying to take a list of existing variable names:
>>
>> NHitMonthsago..00
>> NHitMonthsago.1.00
>> NHitMonthsago.2.00
>> NHitMonthsago.3.00
>> NHitMonthsago.4.00
>> NHitMonthsago.5.00
>> NHitMonthsago.6.00
>> NHitMonthsago.7.00
>> NHitMonthsago.8.00
>> NHitMonthsago.9.00
>> NHitMonthsago.10.00
>> NHitMonthsago.11.00
>> NHitMonthsago.12.00
>>
>>
>> And I would like to add a prefix/suffix to each of the above variable
>> names from values that exist as data in a different variable (I could
>> also store these new values in a set of scratch variables if that is
>> easier).
>>
>> Example Variable “Month1 = May” and I would like to add the “May”
>> value as a prefix to the existing variable name “NHitMonthsago.1.00”
>> with a the existing variable having its new name be “May_
>> NHitMonthsago.1.00”.
>>
>> The value stored in the Month1 variable will change to indicate the
>> current starting month. I have a unique matching variable for each
>> months possiblity.
>>
>> Month0
>> Month1
>> Month2
>> Month3
>> Month4
>> Month5
>> Month6
>> Month7
>> Month8
>> Month9
>> Month10
>> Month11
>>
>> I thought to use a variation of the Macro below, but I can’t quite
>> get how to use a second list of variable data instead of the fixed
>> value “_Suffix”
>>
>> Thank you for any help
>>
>> James Feely
>> Project Manager Data and Analytics.
>>
>> define !rename2 (vlist = !charend('/')
>>                         /suffix=!cmdend )
>>
>> !do !vname !in (!vlist)
>> !let !nname = !concat(!vname, !suffix) rename variables (!vname =
>> !nname).
>> !doend
>> !enddefine.
>>
>> !rename2 vlist =
>> NHitMonthsago..00
>> NHitMonthsago.1.00
>> NHitMonthsago.2.00
>> NHitMonthsago.3.00
>> NHitMonthsago.4.00
>> NHitMonthsago.5.00
>> NHitMonthsago.6.00
>> NHitMonthsago.7.00
>> NHitMonthsago.8.00
>> NHitMonthsago.9.00
>> NHitMonthsago.10.00
>> NHitMonthsago.11.00
>> NHitMonthsago.12.00
>> NHitMonthsago.13.00
>> NHitMonthsago.14.00
>> NHitMonthsago.15.00
>> NHitMonthsago.16.00
>> NHitMonthsago.17.00
>> NHitMonthsago.18.00
>> NHitMonthsago.19.00
>> NHitMonthsago.20.00
>> NHitMonthsago.21.00
>> NHitMonthsago.22.00
>> NHitMonthsago.23.00
>> NHitMonthsago.24.00
>> NHitMonthsago.25.00
>>               /suffix = _Suffix .
>>
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (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
>
>
>
>
>
> -----
> --
> Bruce Weaver

> bweaver@

> http://sites.google.com/a/lakeheadu.ca/bweaver/
>
> "When all else fails, RTFM."
>
> NOTE: My Hotmail account is not monitored regularly.
> To send me an e-mail, please use the address shown above.
>
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/Help-Adding-a-prefix-suf
> fix-to-a-list-of-existing-variable-names-tp5729685p5729690.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Help-Adding-a-prefix-suffix-to-a-list-of-existing-variable-names-tp5729685p5729693.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

=====================
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: Help Adding a prefix/suffix to a list of existing variable names

Jon K Peck
So how do you do those computes?  Wouldn't it be easier for this whole process to just take a string indicating the name of month 0 and use that to generate all the renaming?


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




From:        James Feely <[hidden email]>
To:        [hidden email]
Date:        06/01/2015 04:14 PM
Subject:        Re: [SPSSX-L] Help Adding a prefix/suffix to a list of existing variable names
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hi Bruce exactly,

This syntax get runs run monthly and includes data about web content usage, The variables that I want to change contains information for the past twelve months, I am dumping this out for another user. I am trying to avoid them having to figure out that NHitMonthago.2.00 is the equivalent of April this month and next month it will be May and so on. So I compute what each of the past twelve months are and I can store those values as variable data and then will delete those variables when I don't need them any longer. The value in each variable is the same for every case. It’s a little brute force but it works.

The problem is getting that data from a value in the dataset (or scratch variable) to a suffix attached to a rename of the existing NHitMonthagao.2.00 variable.

I think this can be done in Python, but right now we are having some issue with Python.

I hope this helps clarify what I am trying to accomplish.

Thanks
James

-----Original Message-----
From: SPSSX(r) Discussion [
[hidden email]] On Behalf Of Bruce Weaver
Sent: Monday, June 01, 2015 2:48 PM
To: [hidden email]
Subject: Re: Help Adding a prefix/suffix to a list of existing variable names

Hello James.  Okay, I'll bite.  How is that going to work?  I think what you are saying is you want to rename variables as follows

NHitMonthsago..00  becomes  NHitMonthsago..00_suffix0
NHitMonthsago.1.00 becomes NHitMonthsago.1.00_suffix1
NHitMonthsago.2.00 becomes NHitMonthsago.2.00_suffix2  etc .

where suffix0, suffix1 and suffix2 (etc) are the VALUES of some other variable, or maybe multiple variables.  But those other variables could have have multiple values (perhaps even a different value on every case in the file).  Which one of those multiple possible values do you want to use?

Even if there is only one possible value per variable, you'll still have to figure out how to rename the variables only once (e.g., when $casenum EQ 1) rather than once per every case in the data file.

Perhaps my confusion about what you want to do will prompt someone else to jump in here and sort it all out!  ;-)




James Feely wrote
> Hi Bruce,
>
> Sorry about the post being ran together (first posting). This looks
> like it solves another issue I have, but I am not sure it is exactly
> what I am looking for.
>
> The second set of information needs to be read from a variable in the
> data set, not a predefined list in the macro/syntax. Am I missing something?
>
> Thanks for any additional help. (You are right, this is a neat trick
> :))
>
> James Feely
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:

> SPSSX-L@.UGA

> ] On Behalf Of Bruce Weaver
> Sent: Monday, June 01, 2015 2:11 PM
> To:

> SPSSX-L@.UGA

> Subject: Re: Help Adding a prefix/suffix to a list of existing
> variable names
>
> Yikes!  Your post all ran together in the Nabble archive.  I think it
> is a lot more readable in the quoted section below.  Anyway, I think
> you need to use a trick David Marso showed me once upon a time to
> process in parallel two lists of macro arguments.  See if the
> following (untested) works for you.
>
>
> DEFINE !rename3
>  (vlist = !charend('/') /
>   slist=!cmdend )
>
> !LET !VCOPY=!vlist
> **PARALLEL PROCESS VARIABLE LISTS **
> !DO !suffix !IN (!slist) !LET !V = !HEAD(!VCOPY) !LET
> !VCOPY=!TAIL(!VCOPY)
>
> !do !vname !in (!vlist)
> !let !nname = !concat(!vname, !suffix) rename variables (!vname =
> !nname).
> !DOEND
> !ENDDEFINE.
>
>
>
> James Feely wrote
>> Good morning,
>>
>> I have hit a wall in a current project.
>>
>> I am trying to take a list of existing variable names:
>>
>> NHitMonthsago..00
>> NHitMonthsago.1.00
>> NHitMonthsago.2.00
>> NHitMonthsago.3.00
>> NHitMonthsago.4.00
>> NHitMonthsago.5.00
>> NHitMonthsago.6.00
>> NHitMonthsago.7.00
>> NHitMonthsago.8.00
>> NHitMonthsago.9.00
>> NHitMonthsago.10.00
>> NHitMonthsago.11.00
>> NHitMonthsago.12.00
>>
>>
>> And I would like to add a prefix/suffix to each of the above variable
>> names from values that exist as data in a different variable (I could
>> also store these new values in a set of scratch variables if that is
>> easier).
>>
>> Example Variable “Month1 = May” and I would like to add the “May”
>> value as a prefix to the existing variable name “NHitMonthsago.1.00”
>> with a the existing variable having its new name be “May_
>> NHitMonthsago.1.00”.
>>
>> The value stored in the Month1 variable will change to indicate the
>> current starting month. I have a unique matching variable for each
>> months possiblity.
>>
>> Month0
>> Month1
>> Month2
>> Month3
>> Month4
>> Month5
>> Month6
>> Month7
>> Month8
>> Month9
>> Month10
>> Month11
>>
>> I thought to use a variation of the Macro below, but I can’t quite
>> get how to use a second list of variable data instead of the fixed
>> value “_Suffix”
>>
>> Thank you for any help
>>
>> James Feely
>> Project Manager Data and Analytics.
>>
>> define !rename2 (vlist = !charend('/')
>>                         /suffix=!cmdend )
>>
>> !do !vname !in (!vlist)
>> !let !nname = !concat(!vname, !suffix) rename variables (!vname =
>> !nname).
>> !doend
>> !enddefine.
>>
>> !rename2 vlist =
>> NHitMonthsago..00
>> NHitMonthsago.1.00
>> NHitMonthsago.2.00
>> NHitMonthsago.3.00
>> NHitMonthsago.4.00
>> NHitMonthsago.5.00
>> NHitMonthsago.6.00
>> NHitMonthsago.7.00
>> NHitMonthsago.8.00
>> NHitMonthsago.9.00
>> NHitMonthsago.10.00
>> NHitMonthsago.11.00
>> NHitMonthsago.12.00
>> NHitMonthsago.13.00
>> NHitMonthsago.14.00
>> NHitMonthsago.15.00
>> NHitMonthsago.16.00
>> NHitMonthsago.17.00
>> NHitMonthsago.18.00
>> NHitMonthsago.19.00
>> NHitMonthsago.20.00
>> NHitMonthsago.21.00
>> NHitMonthsago.22.00
>> NHitMonthsago.23.00
>> NHitMonthsago.24.00
>> NHitMonthsago.25.00
>>               /suffix = _Suffix .
>>
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (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
>
>
>
>
>
> -----
> --
> Bruce Weaver

> bweaver@

>
http://sites.google.com/a/lakeheadu.ca/bweaver/
>
> "When all else fails, RTFM."
>
> NOTE: My Hotmail account is not monitored regularly.
> To send me an e-mail, please use the address shown above.
>
> --
> View this message in context:
>
http://spssx-discussion.1045642.n5.nabble.com/Help-Adding-a-prefix-suf
> fix-to-a-list-of-existing-variable-names-tp5729685p5729690.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Help-Adding-a-prefix-suffix-to-a-list-of-existing-variable-names-tp5729685p5729693.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

=====================
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

===================== 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: Help Adding a prefix/suffix to a list of existing variable names

James Feely
In reply to this post by Jon K Peck

Hi Jon,

 

It’s funny, my co-worker Brain mentioned your name and said you might chime in J

 

Anyway, I am basically computing what month it would be for the past 12 months starting from the date the report is run. So one month ago is May, two is April and so on. These value change each month when the report is run.

 

In the main dataset we have an existing variable NHitMonthsago.1.00, NHitMonthsago.2.00 and so on. I want to make it easier on the folks using this information, so I would like to append the correct month value to the end of each of the standard variable names each time the report runs. So if I ran it today then NHitMonthsago.1.00 would become “NHitMonthsago.1.00_May” and “NHitMonthsago.2.00_April”

 

I use the following to compute the relevant month values:

 

COMPUTE Month1=XDATE.MONTH(DATESUM($TIME,-1,"month")).

EXECUTE.

COMPUTE Month2=XDATE.MONTH(DATESUM($TIME,-2,"month")).

EXECUTE.

 

RECODE Month0 Month1 Month2 Month3 Month4 Month5 Month6 Month7 Month8 Month9 Month10 Month11

    ('5.00'='May') ('4.00'='Apr') ('3.00'='Mar') ('2.00'='Feb') ('1.00'='Jan') ('6.00'='Jun')

    ('7.00'='Jul') ('8.00'='Aug') ('9.00'='Sep') ('10.00'='Oct') ('11.00'='Nov') ('12.00'='Dec').

EXECUTE.

 

I hope this helps?

 

James

 

From: Jon K Peck [mailto:[hidden email]]
Sent: Monday, June 01, 2015 2:27 PM
To: James Feely
Cc: [hidden email]
Subject: Re: [SPSSX-L] Help Adding a prefix/suffix to a list of existing variable names

 

Macros cannot refer to case data in any reasonable way while Python can easily do this (as well as all the renaming).  What isn't clear to me is how the data are being used in this process.  Are these constant variables? In the same dataset or another one, or even read from a text file.


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




From:        James Feely <[hidden email]>
To:        [hidden email]
Date:        06/01/2015 03:22 PM
Subject:        Re: [SPSSX-L] Help Adding a prefix/suffix to a list of existing variable names
Sent by:        "SPSSX(r) Discussion" <[hidden email]>





Hi Bruce,

Sorry about the post being ran together (first posting). This looks like it solves another issue I have, but I am not sure it is exactly what I am looking for.

The second set of information needs to be read from a variable in the data set, not a predefined list in the macro/syntax. Am I missing something?

Thanks for any additional help. (You are right, this is a neat trick :))

James Feely

-----Original Message-----
From: SPSSX(r) Discussion [
[hidden email]] On Behalf Of Bruce Weaver
Sent: Monday, June 01, 2015 2:11 PM
To:
[hidden email]
Subject: Re: Help Adding a prefix/suffix to a list of existing variable names

Yikes!  Your post all ran together in the Nabble archive.  I think it is a lot more readable in the quoted section below.  Anyway, I think you need to use a trick David Marso showed me once upon a time to process in parallel two lists of macro arguments.  See if the following (untested) works for you.


DEFINE !rename3
(vlist = !charend('/') /
 slist=!cmdend )

!LET !VCOPY=!vlist
**PARALLEL PROCESS VARIABLE LISTS **
!DO !suffix !IN (!slist) !LET !V = !HEAD(!VCOPY) !LET !VCOPY=!TAIL(!VCOPY)

!do !vname !in (!vlist)
!let !nname = !concat(!vname, !suffix)
rename variables (!vname = !nname).
!DOEND
!ENDDEFINE.



James Feely wrote
> Good morning,
>
> I have hit a wall in a current project.
>
> I am trying to take a list of existing variable names:
>
> NHitMonthsago..00
> NHitMonthsago.1.00
> NHitMonthsago.2.00
> NHitMonthsago.3.00
> NHitMonthsago.4.00
> NHitMonthsago.5.00
> NHitMonthsago.6.00
> NHitMonthsago.7.00
> NHitMonthsago.8.00
> NHitMonthsago.9.00
> NHitMonthsago.10.00
> NHitMonthsago.11.00
> NHitMonthsago.12.00
>
>
> And I would like to add a prefix/suffix to each of the above variable
> names from values that exist as data in a different variable (I could also
> store these new values in a set of scratch variables if that is easier).
>
> Example Variable “Month1 = May” and I would like to add the “May” value as
> a prefix to the existing variable name “NHitMonthsago.1.00” with a the
> existing variable having its new name be “May_ NHitMonthsago.1.00”.
>
> The value stored in the Month1 variable will change to indicate the
> current starting month. I have a unique matching variable for each months
> possiblity.
>
> Month0
> Month1
> Month2
> Month3
> Month4
> Month5
> Month6
> Month7
> Month8
> Month9
> Month10
> Month11
>
> I thought to use a variation of the Macro below, but I can’t quite get how
> to use a second list of variable data instead of the fixed value “_Suffix”
>
> Thank you for any help
>
> James Feely
> Project Manager Data and Analytics.
>
> define !rename2 (vlist = !charend('/')
>                         /suffix=!cmdend )
>
> !do !vname !in (!vlist)
> !let !nname = !concat(!vname, !suffix)
> rename variables (!vname = !nname).
> !doend
> !enddefine.
>
> !rename2 vlist =
> NHitMonthsago..00
> NHitMonthsago.1.00
> NHitMonthsago.2.00
> NHitMonthsago.3.00
> NHitMonthsago.4.00
> NHitMonthsago.5.00
> NHitMonthsago.6.00
> NHitMonthsago.7.00
> NHitMonthsago.8.00
> NHitMonthsago.9.00
> NHitMonthsago.10.00
> NHitMonthsago.11.00
> NHitMonthsago.12.00
> NHitMonthsago.13.00
> NHitMonthsago.14.00
> NHitMonthsago.15.00
> NHitMonthsago.16.00
> NHitMonthsago.17.00
> NHitMonthsago.18.00
> NHitMonthsago.19.00
> NHitMonthsago.20.00
> NHitMonthsago.21.00
> NHitMonthsago.22.00
> NHitMonthsago.23.00
> NHitMonthsago.24.00
> NHitMonthsago.25.00
>               /suffix = _Suffix .
>
>
> =====================
> 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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Help-Adding-a-prefix-suffix-to-a-list-of-existing-variable-names-tp5729685p5729690.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

=====================
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

===================== 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: Help Adding a prefix/suffix to a list of existing variable names

David Marso
Administrator
In reply to this post by Bruce Weaver
Here is another way to do parallel list processing.
--
DEFINE !par_rec (!POS !CHAREND("/")/!POS !CHAREND("/")/!POS !CHAREND("/") /!POS !CHAREND("/") )
!IF (!1 !NE "") !THEN
!par_rec !TAIL(!1) / !TAIL(!2) / !CONCAT(!3," ",!HEAD(!1)) / !CONCAT(!4," ",!HEAD(!1),!HEAD(!2))
!ELSE
RENAME VARIABLES (!3 = !4 ).
!IFEND
!ENDDEFINE .

SET MPRINT ON PRINTBACK ON.
!par_rec a b c  / 1 2 3  / / .

!par_rec a b c  / 1 2 3  / / .
  33  0 M>  
  34  0 M>  .
  35  0 M>  RENAME VARIABLES ( a b c = a1 b2 c3 ).

Bruce Weaver wrote
Yikes!  Your post all ran together in the Nabble archive.  I think it is a lot more readable in the quoted section below.  Anyway, I think you need to use a trick David Marso showed me once upon a time to process in parallel two lists of macro arguments.  See if the following (untested) works for you.


DEFINE !rename3
 (vlist = !charend('/') /
  slist=!cmdend )

!LET !VCOPY=!vlist
**PARALLEL PROCESS VARIABLE LISTS **
!DO !suffix !IN (!slist) !LET !V = !HEAD(!VCOPY) !LET !VCOPY=!TAIL(!VCOPY)

!do !vname !in (!vlist)
!let !nname = !concat(!vname, !suffix)
rename variables (!vname = !nname).
!DOEND
!ENDDEFINE.


James Feely wrote
Good morning,

I have hit a wall in a current project.

I am trying to take a list of existing variable names:

NHitMonthsago..00
NHitMonthsago.1.00
NHitMonthsago.2.00
NHitMonthsago.3.00
NHitMonthsago.4.00
NHitMonthsago.5.00
NHitMonthsago.6.00
NHitMonthsago.7.00
NHitMonthsago.8.00
NHitMonthsago.9.00
NHitMonthsago.10.00
NHitMonthsago.11.00
NHitMonthsago.12.00


And I would like to add a prefix/suffix to each of the above variable names from values that exist as data in a different variable (I could also store these new values in a set of scratch variables if that is easier).

Example Variable “Month1 = May” and I would like to add the “May” value as a prefix to the existing variable name “NHitMonthsago.1.00” with a the existing variable having its new name be “May_ NHitMonthsago.1.00”.

The value stored in the Month1 variable will change to indicate the current starting month. I have a unique matching variable for each months possiblity.

Month0
Month1
Month2
Month3
Month4
Month5
Month6
Month7
Month8
Month9
Month10
Month11

I thought to use a variation of the Macro below, but I can’t quite get how to use a second list of variable data instead of the fixed value “_Suffix”

Thank you for any help

James Feely
Project Manager Data and Analytics.

define !rename2 (vlist = !charend('/')
                        /suffix=!cmdend )

!do !vname !in (!vlist)
!let !nname = !concat(!vname, !suffix)
rename variables (!vname = !nname).
!doend
!enddefine.

!rename2 vlist =
NHitMonthsago..00
NHitMonthsago.1.00
NHitMonthsago.2.00
NHitMonthsago.3.00
NHitMonthsago.4.00
NHitMonthsago.5.00
NHitMonthsago.6.00
NHitMonthsago.7.00
NHitMonthsago.8.00
NHitMonthsago.9.00
NHitMonthsago.10.00
NHitMonthsago.11.00
NHitMonthsago.12.00
NHitMonthsago.13.00
NHitMonthsago.14.00
NHitMonthsago.15.00
NHitMonthsago.16.00
NHitMonthsago.17.00
NHitMonthsago.18.00
NHitMonthsago.19.00
NHitMonthsago.20.00
NHitMonthsago.21.00
NHitMonthsago.22.00
NHitMonthsago.23.00
NHitMonthsago.24.00
NHitMonthsago.25.00
              /suffix = _Suffix .


=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Help Adding a prefix/suffix to a list of existing variable names

David Marso
Administrator
In reply to this post by David Marso
HORRIBLE HACK TIME?
--

DEFINE !par_rec (!POS !CHAREND("/")/!POS !CHAREND("/")/!POS !CHAREND("/") /!POS !CHAREND("/") )
!IF (!1 !NE "") !THEN
!par_rec !TAIL(!1) / !TAIL(!2) / !CONCAT(!3," ",!HEAD(!1)) / !CONCAT(!4," ",!HEAD(!1),!HEAD(!2))
!ELSE
RENAME VARIABLES (!3 = !4 ).
!IFEND
!ENDDEFINE .

DATA LIST FREE / x y z (3F1) m1 m2 m3 (3A1).
BEGIN DATA
1 2 3 a b c
4 5 6 a b c
7 8 9 a b c
END DATA.
DATASET NAME raw.
DATASET COPY copy.
DATASET ACTIVATE copy.
SELECT IF $CASENUM EQ 1.
VARSTOCASES MAKE n FROM x y z / MAKE p FROM m1 m2 m3 /INDEX=root(n).
DELETE VARIABLES n.
CASESTOVARS.
WRITE OUTFILE 'G:\TEMP\macrotemp.sps'  / '!par_rec ' root.1 TO root.3 (3A20) '/' p.1 TO p.3 (3A20)  '//.'.
EXECUTE.
DATASET ACTIVATE RAW.
INSERT FILE =  'G:\TEMP\macrotemp.sps'.
ERASE FILE  'G:\TEMP\macrotemp.sps'.


Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Help Adding a prefix/suffix to a list of existing variable names

Elizabeth Tighe
In reply to this post by James Feely
If you can call R from SPSS, there is a paste function that I use to do what you describe. e.g.,

newvar <- paste(prefixvar, targetvar, sep='.')

?



On Jun 1, 2015, at 6:26 PM, James Feely <[hidden email]> wrote:

Hi Jon,

 

It’s funny, my co-worker Brain mentioned your name and said you might chime in J

 

Anyway, I am basically computing what month it would be for the past 12 months starting from the date the report is run. So one month ago is May, two is April and so on. These value change each month when the report is run.

 

In the main dataset we have an existing variable NHitMonthsago.1.00, NHitMonthsago.2.00 and so on. I want to make it easier on the folks using this information, so I would like to append the correct month value to the end of each of the standard variable names each time the report runs. So if I ran it today then NHitMonthsago.1.00 would become “NHitMonthsago.1.00_May” and “NHitMonthsago.2.00_April”

 

I use the following to compute the relevant month values:

 

COMPUTE Month1=XDATE.MONTH(DATESUM($TIME,-1,"month")).

EXECUTE.

COMPUTE Month2=XDATE.MONTH(DATESUM($TIME,-2,"month")).

EXECUTE.

 

RECODE Month0 Month1 Month2 Month3 Month4 Month5 Month6 Month7 Month8 Month9 Month10 Month11

    ('5.00'='May') ('4.00'='Apr') ('3.00'='Mar') ('2.00'='Feb') ('1.00'='Jan') ('6.00'='Jun')

    ('7.00'='Jul') ('8.00'='Aug') ('9.00'='Sep') ('10.00'='Oct') ('11.00'='Nov') ('12.00'='Dec').

EXECUTE.

 

I hope this helps?

 

James

 

From: Jon K Peck [[hidden email]]
Sent: Monday, June 01, 2015 2:27 PM
To: James Feely
Cc: [hidden email]
Subject: Re: [SPSSX-L] Help Adding a prefix/suffix to a list of existing variable names

 

Macros cannot refer to case data in any reasonable way while Python can easily do this (as well as all the renaming).  What isn't clear to me is how the data are being used in this process.  Are these constant variables? In the same dataset or another one, or even read from a text file.


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




From:        James Feely <[hidden email]>
To:        [hidden email]
Date:        06/01/2015 03:22 PM
Subject:        Re: [SPSSX-L] Help Adding a prefix/suffix to a list of existing variable names
Sent by:        "SPSSX(r) Discussion" <[hidden email]>





Hi Bruce,

Sorry about the post being ran together (first posting). This looks like it solves another issue I have, but I am not sure it is exactly what I am looking for.

The second set of information needs to be read from a variable in the data set, not a predefined list in the macro/syntax. Am I missing something?

Thanks for any additional help. (You are right, this is a neat trick :))

James Feely

-----Original Message-----
From: SPSSX(r) Discussion [
[hidden email]] On Behalf Of Bruce Weaver
Sent: Monday, June 01, 2015 2:11 PM
To:
[hidden email]
Subject: Re: Help Adding a prefix/suffix to a list of existing variable names

Yikes!  Your post all ran together in the Nabble archive.  I think it is a lot more readable in the quoted section below.  Anyway, I think you need to use a trick David Marso showed me once upon a time to process in parallel two lists of macro arguments.  See if the following (untested) works for you.


DEFINE !rename3
(vlist = !charend('/') /
 slist=!cmdend )

!LET !VCOPY=!vlist
**PARALLEL PROCESS VARIABLE LISTS **
!DO !suffix !IN (!slist) !LET !V = !HEAD(!VCOPY) !LET !VCOPY=!TAIL(!VCOPY)

!do !vname !in (!vlist)
!let !nname = !concat(!vname, !suffix)
rename variables (!vname = !nname).
!DOEND
!ENDDEFINE.



James Feely wrote
> Good morning,
>
> I have hit a wall in a current project.
>
> I am trying to take a list of existing variable names:
>
> NHitMonthsago..00
> NHitMonthsago.1.00
> NHitMonthsago.2.00
> NHitMonthsago.3.00
> NHitMonthsago.4.00
> NHitMonthsago.5.00
> NHitMonthsago.6.00
> NHitMonthsago.7.00
> NHitMonthsago.8.00
> NHitMonthsago.9.00
> NHitMonthsago.10.00
> NHitMonthsago.11.00
> NHitMonthsago.12.00
>
>
> And I would like to add a prefix/suffix to each of the above variable
> names from values that exist as data in a different variable (I could also
> store these new values in a set of scratch variables if that is easier).
>
> Example Variable “Month1 = May” and I would like to add the “May” value as
> a prefix to the existing variable name “NHitMonthsago.1.00” with a the
> existing variable having its new name be “May_ NHitMonthsago.1.00”.
>
> The value stored in the Month1 variable will change to indicate the
> current starting month. I have a unique matching variable for each months
> possiblity.
>
> Month0
> Month1
> Month2
> Month3
> Month4
> Month5
> Month6
> Month7
> Month8
> Month9
> Month10
> Month11
>
> I thought to use a variation of the Macro below, but I can’t quite get how
> to use a second list of variable data instead of the fixed value “_Suffix”
>
> Thank you for any help
>
> James Feely
> Project Manager Data and Analytics.
>
> define !rename2 (vlist = !charend('/')
>                         /suffix=!cmdend )
>
> !do !vname !in (!vlist)
> !let !nname = !concat(!vname, !suffix)
> rename variables (!vname = !nname).
> !doend
> !enddefine.
>
> !rename2 vlist =
> NHitMonthsago..00
> NHitMonthsago.1.00
> NHitMonthsago.2.00
> NHitMonthsago.3.00
> NHitMonthsago.4.00
> NHitMonthsago.5.00
> NHitMonthsago.6.00
> NHitMonthsago.7.00
> NHitMonthsago.8.00
> NHitMonthsago.9.00
> NHitMonthsago.10.00
> NHitMonthsago.11.00
> NHitMonthsago.12.00
> NHitMonthsago.13.00
> NHitMonthsago.14.00
> NHitMonthsago.15.00
> NHitMonthsago.16.00
> NHitMonthsago.17.00
> NHitMonthsago.18.00
> NHitMonthsago.19.00
> NHitMonthsago.20.00
> NHitMonthsago.21.00
> NHitMonthsago.22.00
> NHitMonthsago.23.00
> NHitMonthsago.24.00
> NHitMonthsago.25.00
>               /suffix = _Suffix .
>
>
> =====================
> 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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Help-Adding-a-prefix-suffix-to-a-list-of-existing-variable-names-tp5729685p5729690.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

=====================
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

===================== 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
===================== 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: Help Adding a prefix/suffix to a list of existing variable names

Richard Ristow
In reply to this post by James Feely
At 12:41 PM 5/29/2015, James Feely wrote:
>I am trying to take a list of existing variable names:
>
>NHitMonthsago..00
...
>NHitMonthsago.12.00

>And I would like to add a prefix/suffix to each of the above
>variable names from values that exist as data in a different variable.
>
>Example Variable "Month1 = May" and I would like to add the "May"
>value as a prefix to the existing variable name "NHitMonthsago.1.00"
>with a the existing variable having its new name be "May_ NHitMonthsago.1.00".

I don't have time to work details for your problem now, but
CASESTOVARS can be used to append a suffix to a set of variable
names;  this can be handy, even when you aren't actually combining
several cases into one.

=====================
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