Re: SPSSX-L Digest - 14 Jul 2008 to 15 Jul 2008 (#2008-196)

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

Re: SPSSX-L Digest - 14 Jul 2008 to 15 Jul 2008 (#2008-196)

D.R. Wahlgren
>Date:    Tue, 15 Jul 2008 09:46:56 -0400
>From:    Gene Maguin <[hidden email]>
>Subject: Re: Search for a value in all variables?
>
>Dennis,
>
>>>I'd like to do two things: 1) identify the case and variable for each
>instance of a -8, and 2) create a new variable that simply flags the
>presence of at least one -8 on the case with a dichotomous (0/1)
>variable.
>
>>>Oh, and to complicate it just a bit more, a small number of the
>variables are string.
>
>Task 1) Use a recode statement to create a set of corresponding indicator
>variables. Like this
>
>Recode x1 to x500(-8=1)(else=0) into n8_1 to n8_500.
>Recode s501 to s508('-8'=1)(else=0) into n8_501 to n8_508.


Thanks, Gene.  Will this work if the string variables are
interspersed throughout the numeric variables?  There aren't clean
groups of variables by type.  Can I run something like this?

Recode x1 to x500(-8, '-8' =1)(else=0) into n8_1 to n8_500.

(Albert-Jan's suggestion to convert the string to numeric variables
is interesting, too, but most of my string variables have valid
string data in them, so I think the command would produce an error.)

_dennis

=====================
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: SPSSX-L Digest - 14 Jul 2008 to 15 Jul 2008 (#2008-196)

Peck, Jon
It is easy to pick out variables by type using programmability.

E.g.

Begin program.
Import spss, spssaux
Numvars eq " ".join(spssaux.variableDict(variableType eq "numeric").variables)

Etc
End program.

Eq is an equals sign.
Check argument details in the spssaux module.

It's hard to program on a BlackBerry.

HTH,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion <[hidden email]>
To: [hidden email] <[hidden email]>
Sent: Wed Jul 16 12:15:23 2008
Subject:      Re: [SPSSX-L] SPSSX-L Digest - 14 Jul 2008 to 15 Jul 2008              (#2008-196)

>Date:    Tue, 15 Jul 2008 09:46:56 -0400
>From:    Gene Maguin <[hidden email]>
>Subject: Re: Search for a value in all variables?
>
>Dennis,
>
>>>I'd like to do two things: 1) identify the case and variable for each
>instance of a -8, and 2) create a new variable that simply flags the
>presence of at least one -8 on the case with a dichotomous (0/1)
>variable.
>
>>>Oh, and to complicate it just a bit more, a small number of the
>variables are string.
>
>Task 1) Use a recode statement to create a set of corresponding indicator
>variables. Like this
>
>Recode x1 to x500(-8=1)(else=0) into n8_1 to n8_500.
>Recode s501 to s508('-8'=1)(else=0) into n8_501 to n8_508.


Thanks, Gene.  Will this work if the string variables are
interspersed throughout the numeric variables?  There aren't clean
groups of variables by type.  Can I run something like this?

Recode x1 to x500(-8, '-8' =1)(else=0) into n8_1 to n8_500.

(Albert-Jan's suggestion to convert the string to numeric variables
is interesting, too, but most of my string variables have valid
string data in them, so I think the command would produce an error.)

_dennis

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