|
Gang,
Is there a way to search for a specific value on *all* variables in a data set without naming every variable in the syntax commands? For example, if I want to locate every instance of a -8 (our code for a refusal) across all 500+ variables in my data set, how would I go about it? 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. If they could be included in the search, that would be great, but I would be ok with omitting them from this search if there was a relatively simple way to do it (I'd rather not have to name them all on a DROP subcommand but will if necessary.) I'm using v16 for Mac. thanks, 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 |
|
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. Now task 2) is easy. I like a count command but you might also be able to use an ANY function. Count n8s=n8_1 to n8_508(1). Gene Maguin ===================== 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 |
|
In reply to this post by D.R. Wahlgren
Try the count command and use ALL or x TO y to specify the variables to check.
HTH, Jon Peck ------Original Message------ From: D.R. Wahlgren To: SPSSX-L ReplyTo: D.R. Wahlgren Sent: Jul 15, 2008 2:28 AM Subject: [SPSSX-L] Search for a value in all variables? Gang, Is there a way to search for a specific value on *all* variables in a data set without naming every variable in the syntax commands? For example, if I want to locate every instance of a -8 (our code for a refusal) across all 500+ variables in my data set, how would I go about it? 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. If they could be included in the search, that would be great, but I would be ok with omitting them from this search if there was a relatively simple way to do it (I'd rather not have to name them all on a DROP subcommand but will if necessary.) I'm using v16 for Mac. thanks, 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 |
|
At 11:42 AM -0500 7/15/08, Peck, Jon wrote:
>Try the count command and use ALL or x TO y to specify the variables to check. Thanks, Jon. Will this work with string variables included in the range? Can I specify (-8 or "-8") for the values to be counted? thanks! Dennis > >------Original Message------ >From: D.R. Wahlgren >To: SPSSX-L >ReplyTo: D.R. Wahlgren >Sent: Jul 15, 2008 2:28 AM >Subject: [SPSSX-L] Search for a value in all variables? > >Gang, >Is there a way to search for a specific value on *all* variables in a >data set without naming every variable in the syntax commands? For >example, if I want to locate every instance of a -8 (our code for a >refusal) across all 500+ variables in my data set, how would I go >about it? > >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. If they could be included in the search, that >would be great, but I would be ok with omitting them from this search >if there was a relatively simple way to do it (I'd rather not have to >name them all on a DROP subcommand but will if necessary.) > >I'm using v16 for Mac. > >thanks, >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 |
|
Hi,
Before using COUNT, you could convert the string variables to their numerical equivalent using the NUMBER function. compute new = number(old, f5). Cheers!! Albert-Jan --- On Tue, 7/15/08, D.R. Wahlgren <[hidden email]> wrote: > From: D.R. Wahlgren <[hidden email]> > Subject: Re: Search for a value in all variables? > To: [hidden email] > Date: Tuesday, July 15, 2008, 6:52 PM > At 11:42 AM -0500 7/15/08, Peck, Jon wrote: > >Try the count command and use ALL or x TO y to specify > the variables to check. > > Thanks, Jon. Will this work with string variables included > in the > range? Can I specify (-8 or "-8") for the values > to be counted? > > thanks! > Dennis > > > > >------Original Message------ > >From: D.R. Wahlgren > >To: SPSSX-L > >ReplyTo: D.R. Wahlgren > >Sent: Jul 15, 2008 2:28 AM > >Subject: [SPSSX-L] Search for a value in all > variables? > > > >Gang, > >Is there a way to search for a specific value on *all* > variables in a > >data set without naming every variable in the syntax > commands? For > >example, if I want to locate every instance of a -8 > (our code for a > >refusal) across all 500+ variables in my data set, how > would I go > >about it? > > > >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. If they could be included in the > search, that > >would be great, but I would be ok with omitting them > from this search > >if there was a relatively simple way to do it (I'd > rather not have to > >name them all on a DROP subcommand but will if > necessary.) > > > >I'm using v16 for Mac. > > > >thanks, > >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 ===================== 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 |
|
In reply to this post by Maguin, Eugene
At 09:46 AM 7/15/2008, Gene Maguin wrote:
>> >>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. 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. > >Count n8s=n8_1 to n8_508(1). Right. But it's a good idea to use scratch variables for values, like n8_1 to n8_508, that exist solely as intermediate values in a calculation: 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. Count n8s=#n8_1 to #n8_508(1). ===================== 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 |
| Free forum by Nabble | Edit this page |
