modified variable names and macros

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

modified variable names and macros

Konecny Tomas
 
 
Hello,  
I wanted to convert a large number (+100) of numeric variables into string variables having similar, yet slightly modified name. Is it possible to define a macro that uses the names of the existing variables to generate new variables?  
For example I have numeric vars called age sex etc. and want to have string vars age1 sex1 etc.  
Thanks a lot for any advice,  
Tomas Konecny  

 

====================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: modified variable names and macros

Spousta Jan
Hello Tomáš,

Try this:

define to_str (!pos=!cmd).

!do !i !in (!1)
string !concat(!i, "1") (a4).
compute !concat(!i, "1") = string(!i, f4).
!doend

execute.
!enddefine.

to_str age sex edu.

Best regards,

Jan

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Konecny Tomas
Sent: Monday, March 10, 2008 9:41 AM
To: [hidden email]
Subject: modified variable names and macros



Hello,
I wanted to convert a large number (+100) of numeric variables into string variables having similar, yet slightly modified name. Is it possible to define a macro that uses the names of the existing variables to generate new variables?
For example I have numeric vars called age sex etc. and want to have string vars age1 sex1 etc.
Thanks a lot for any advice,
Tomas Konecny



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



_____

Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem.

This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission.

-.- --

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