Var names in expresions

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

Var names in expresions

Kolodziejczyk, Piotr
Hi!
I've some variables in format: a1_1, a1_2, a1_3, a1_4.... And they are
binary type (0-no, 1-yes).
I'd like to create new variable whith name: "a1",  stirng type, and
values as:
"1;2;3"
"1;3"
"2;4;5"
 indicated whether a1_1, a1_2,a1_3 (in the first case)  are
simultaneously selected, in second case: a1_1, a1_3  and so on...

I've several sets of these variables, so how to recall and make some
modifications on variable names operating with vectors or some other
way...?

I need sth like:
Vector v=a1_1 to a1_10.
Loop #i=1 to 10.
If (v(#i)=1)  some_var=LastCharacterOf(v).

Only Python?

Regards,
Piotr

=====================
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: Var names in expresions

Spousta Jan
Hi Piotr,
Try this:

string a1 (a50).
do repe x = a1_1 to a1_4 / n = 1 to 4.
- do if (x > 0).
-   if length(rtrim(a1)) > 0 a1 = concat(rtrim(a1),";").
-   compute a1 = concat(rtrim(a1),string(n,f1)).
- end if.
end repe.
exe.

Best,

Jan


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Kolodziejczyk, Piotr
Sent: Wednesday, November 07, 2007 3:00 PM
To: [hidden email]
Subject: Var names in expresions

Hi!
I've some variables in format: a1_1, a1_2, a1_3, a1_4.... And they are binary type (0-no, 1-yes).
I'd like to create new variable whith name: "a1",  stirng type, and values as:
"1;2;3"
"1;3"
"2;4;5"
 indicated whether a1_1, a1_2,a1_3 (in the first case)  are simultaneously selected, in second case: a1_1, a1_3  and so on...

I've several sets of these variables, so how to recall and make some modifications on variable names operating with vectors or some other way...?

I need sth like:
Vector v=a1_1 to a1_10.
Loop #i=1 to 10.
If (v(#i)=1)  some_var=LastCharacterOf(v).

Only Python?

Regards,
Piotr

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