Doing Multipel Tranformations

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

Doing Multipel Tranformations

Joseph Schneider
Hello all,

I need to run the following code

do if (Q10A_99_01_1=1).
Recode Q10A_01 (missing=99).
end if.
Execute.

For Variables Q10X_99_Y
Where X starts at A and Ends at G, and Y starts at 1 and ends at 17

The Variables are
Q10A_99_01...Q10A_99_17
Q10B_99_01...Q10B_99_17
.
.
.
.
Q10G_99_01....Q10G_99_17

I need to recode Variable Q10X_Y
Where X starts at A and Ends at G, and Y starts at 1 and ends at 17

Q10A_01...Q10A_17
Q10B_01...Q10B_17
.
.
.
.
Q10G_01....Q10G_17


Is there Syntax I can use to drop each letter number combination into the
Do If code so I do not have to make 136 seperate statements?

Thank You,
Joe

=====================
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: Doing Multipel Tranformations

Maguin, Eugene
Joseph,

My first thought was a macro but I actually think you can do this with a Do
Repeat command structure. Read the documentation in the syntax reference but
I'd set it up like this.

Do repeat
   x=Q10A_99_01...Q10A_99_17 Q10B_99_01...Q10B_99_17/
   y=Q10A_01...Q10A_17 Q10B_01...Q10B_17.
+  do if (Q10A_99_01_1=1).
+     Recode Q10A_01 (missing=99).
+  end if.
End repeat.

You will need to list all the variables unless they are carefully, correctly
arranged, which you can do with a Match files command, in which case you can
use the 'TO' convention.

Gene Maguin


>>I need to run the following code

do if (Q10A_99_01_1=1).
Recode Q10A_01 (missing=99).
end if.
Execute.

For Variables Q10X_99_Y
Where X starts at A and Ends at G, and Y starts at 1 and ends at 17

The Variables are
Q10A_99_01...Q10A_99_17
Q10B_99_01...Q10B_99_17
.
.
.
.
Q10G_99_01....Q10G_99_17

I need to recode Variable Q10X_Y
Where X starts at A and Ends at G, and Y starts at 1 and ends at 17

Q10A_01...Q10A_17
Q10B_01...Q10B_17
.
.
.
.
Q10G_01....Q10G_17


Is there Syntax I can use to drop each letter number combination into the
Do If code so I do not have to make 136 seperate statements?

Thank You,
Joe

=====================
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: Doing Multipel Tranformations

Bruce Weaver
Administrator
Gene Maguin wrote
Joseph,

My first thought was a macro but I actually think you can do this with a Do
Repeat command structure. Read the documentation in the syntax reference but
I'd set it up like this.

Do repeat
   x=Q10A_99_01...Q10A_99_17 Q10B_99_01...Q10B_99_17/
   y=Q10A_01...Q10A_17 Q10B_01...Q10B_17.
+  do if (Q10A_99_01_1=1).
+     Recode Q10A_01 (missing=99).
+  end if.
End repeat.

You will need to list all the variables unless they are carefully, correctly
arranged, which you can do with a Match files command, in which case you can
use the 'TO' convention.

Gene Maguin
I too was thinking DO-REPEAT would work.  Note Gene's typo though.  I think he meant:

Do repeat
   x=Q10A_99_01...Q10A_99_17 Q10B_99_01...Q10B_99_17/
   y=Q10A_01...Q10A_17 Q10B_01...Q10B_17.
+  do if (x=1).
+     Recode y (missing=99).
+  end if.
End repeat.

--
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/).