Counting Occurances Across Many Columns

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

Counting Occurances Across Many Columns

Joseph Schneider
I am a relative newcomer to SPSS and using Syntax, and have problem that I
am have been unable to solve so far.
I have 10 Variables, and 200 cases with 20 possible values (1-20) that are
the same for each variable.  I and would like to check each variable for
each case and determine if the value is present, and then use syntax to
create another variable letting me know if it found any of the variable
values across all 10 Variables.

Data would look like

Case    V1 V2...V10
1       1   5    15
2       2   5    18

And then I want to be able to create a new variable for if found each value
in any of the cases.

So the output would look like

Case   V1 V2....V10  1  2  3  4  5 ...15...18 19 20
1       1 5      15  Y                 Y
2       2 5      18     y                   y

This is actually Doable, but painstaking in Excel, so I am sure SPSS has a
more elegant solution around this.

Thank You
Joe
[hidden email]

=====================
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: Counting Occurances Across Many Columns

Marks, Jim
Joe:

You can use the COUNT function.

COUNT found_1 = V1 TO V10 (1).
COUNT found_2 = VI TO v10 (2).

RECODE found_1 TO found_20 (1 THRU HI) = 1 (0 = 0).

I think it is possible create syntax that will loop thru the values, but
I usually copy, paste and edit.

--jim


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Joseph Schneider
Sent: Wednesday, June 18, 2008 9:39 PM
To: [hidden email]
Subject: Counting Occurances Across Many Columns

I am a relative newcomer to SPSS and using Syntax, and have problem that
I
am have been unable to solve so far.
I have 10 Variables, and 200 cases with 20 possible values (1-20) that
are
the same for each variable.  I and would like to check each variable for
each case and determine if the value is present, and then use syntax to
create another variable letting me know if it found any of the variable
values across all 10 Variables.

Data would look like

Case    V1 V2...V10
1       1   5    15
2       2   5    18

And then I want to be able to create a new variable for if found each
value
in any of the cases.

So the output would look like

Case   V1 V2....V10  1  2  3  4  5 ...15...18 19 20
1       1 5      15  Y                 Y
2       2 5      18     y                   y

This is actually Doable, but painstaking in Excel, so I am sure SPSS has
a
more elegant solution around this.

Thank You
Joe
[hidden email]

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