Handling repeated cases

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

Handling repeated cases

Peter Spangler
Hi All,

My data looks like this:

UserID Var1 
1         string
1         string
1         string
1         string
1         string

I'd like to select all "string" for each identical case and move them into columns, variables of their own to be associated with that case.
Any ideas?
Reply | Threaded
Open this post in threaded view
|

Re: Handling repeated cases

David Marso
Administrator
P.,
Brevity ~= virtue!
Ex of I/O?.
D.
Peter Spangler wrote
Hi All,

My data looks like this:

UserID Var1
1         string
1         string
1         string
1         string
1         string

I'd like to select all "string" for each identical case and move them into
columns, variables of their own to be associated with that case.
Any ideas?
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Handling repeated cases

Maguin, Eugene
In reply to this post by Peter Spangler

One command: casestovars. If that doesn’t give you what you want, repost with an example with values for var1 that illustrate the problem and what the structure will look like after the restructure.

 

Gene Maguin

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Peter Spangler
Sent: Friday, March 15, 2013 8:52 PM
To: [hidden email]
Subject: Handling repeated cases

 

Hi All,

 

My data looks like this:

 

UserID Var1 

1         string

1         string

1         string

1         string

1         string

 

I'd like to select all "string" for each identical case and move them into columns, variables of their own to be associated with that case.

Any ideas?

Reply | Threaded
Open this post in threaded view
|

Re: Handling repeated cases

Peter Spangler
The goal is to restructure data such that the unique IDs can be analyzed based on belonging to specific groups. Respondents have selected groups to "Like" online. I see each group being a variable (column) coded 0/1, yes/no. Respondents could then be analyzed for their odds of belonging to group A given group B, Clustered, etc.

Data example: I'd like to make Music, Restaurants and Games variables and have ID 1 appear once. In this case ID 1 would be coded 1 for variables Music, Restaurants, Games.

ID  Likes
1            Music
1            Restaurants
1            Games





On Sat, Mar 16, 2013 at 7:25 AM, Maguin, Eugene <[hidden email]> wrote:

One command: casestovars. If that doesn’t give you what you want, repost with an example with values for var1 that illustrate the problem and what the structure will look like after the restructure.

 

Gene Maguin

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Peter Spangler
Sent: Friday, March 15, 2013 8:52 PM
To: [hidden email]
Subject: Handling repeated cases

 

Hi All,

 

My data looks like this:

 

UserID Var1 

1         string

1         string

1         string

1         string

1         string

 

I'd like to select all "string" for each identical case and move them into columns, variables of their own to be associated with that case.

Any ideas?


Reply | Threaded
Open this post in threaded view
|

Re: Handling repeated cases

David Marso
Administrator
CASESTOVARS is the heavy lifter here but a bit of mojo in the middle crosses the bridge.
* NOTE fake element @ at top with stand-in 0 id.
I believe this is as slick as it gets (without hardcoding unknown variable names into the recode).
--
DATA LIST LIST/id (F2) S (A20).
BEGIN DATA
0            @             /* note fake case here */
1            Music
1            Restaurants
1            Games
2            Music
2            Concerts
2            Animals
END DATA.

AUTORECODE S /INTO NS.
CASESTOVARS /ID=ID / INDEX=S.
COMPUTE @@=1.
RECODE @ TO @@ (SYSMIS=0)(ELSE=1).
SELECT IF ID NE 0.
EXECUTE /* need this EXECUTE or else DELETE VARIABLES gives error */.
DELETE VARIABLES @ @@.
LIST.

id Animals Concerts Games Music Restaurants

 1    0        0      1     1        1
 2    1        1      0     1        0


Number of cases read:  2    Number of cases listed:  2
Peter Spangler wrote
The goal is to restructure data such that the unique IDs can be analyzed
based on belonging to specific groups. Respondents have selected groups to
"Like" online. I see each group being a variable (column) coded 0/1,
yes/no. Respondents could then be analyzed for their odds of belonging to
group A given group B, Clustered, etc.

Data example: I'd like to make Music, Restaurants and Games variables and
have ID 1 appear once. In this case ID 1 would be coded 1 for variables
Music, Restaurants, Games.

*ID*  *Likes*
1            Music
1            Restaurants
1            Games





On Sat, Mar 16, 2013 at 7:25 AM, Maguin, Eugene <[hidden email]> wrote:

> One command: casestovars. If that doesn’t give you what you want, repost
> with an example with values for var1 that illustrate the problem and what
> the structure will look like after the restructure.****
>
> ** **
>
> Gene Maguin****
>
> ** **
>
> *From:* SPSSX(r) Discussion [mailto:[hidden email]] *On Behalf
> Of *Peter Spangler
> *Sent:* Friday, March 15, 2013 8:52 PM
> *To:* [hidden email]
> *Subject:* Handling repeated cases****
>
> ** **
>
> Hi All,****
>
> ** **
>
> My data looks like this:****
>
> ** **
>
> UserID Var1 ****
>
> 1         string****
>
> 1         string****
>
> 1         string****
>
> 1         string****
>
> 1         string****
>
> ** **
>
> I'd like to select all "string" for each identical case and move them into
> columns, variables of their own to be associated with that case.****
>
> Any ideas?****
>
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Handling repeated cases

Peter Spangler
Wow! Thank you David. This is what I was looking for. Essentially I can copy my IDs and Strings as is below and the scratch variable is to set others to 0?

On Mon, Mar 18, 2013 at 9:34 AM, David Marso <[hidden email]> wrote:
CASESTOVARS is the heavy lifter here but a bit of mojo in the middle crosses
the bridge.
* NOTE fake element @ at top with stand-in 0 id.
I believe this is as slick as it gets (without hardcoding unknown variable
names into the recode).
--
DATA LIST LIST/id (F2) S (A20).
BEGIN DATA
0            @             /* note fake case here */
1            Music
1            Restaurants
1            Games
2            Music
2            Concerts
2            Animals
END DATA.

AUTORECODE S /INTO NS.
CASESTOVARS /ID=ID / INDEX=S.
COMPUTE @@=1.
RECODE @ TO @@ (SYSMIS=0)(ELSE=1).
SELECT IF ID NE 0.
EXECUTE /* need this EXECUTE or else DELETE VARIABLES gives error */.
DELETE VARIABLES @ @@.
LIST.

id Animals Concerts Games Music Restaurants

 1    0        0      1     1        1
 2    1        1      0     1        0


Number of cases read:  2    Number of cases listed:  2

Peter Spangler wrote
> The goal is to restructure data such that the unique IDs can be analyzed
> based on belonging to specific groups. Respondents have selected groups to
> "Like" online. I see each group being a variable (column) coded 0/1,
> yes/no. Respondents could then be analyzed for their odds of belonging to
> group A given group B, Clustered, etc.
>
> Data example: I'd like to make Music, Restaurants and Games variables and
> have ID 1 appear once. In this case ID 1 would be coded 1 for variables
> Music, Restaurants, Games.
>
> *ID*  *Likes*
> 1            Music
> 1            Restaurants
> 1            Games
>
>
>
>
>
> On Sat, Mar 16, 2013 at 7:25 AM, Maguin, Eugene &lt;

> emaguin@

> &gt; wrote:
>
>> One command: casestovars. If that doesn’t give you what you want, repost
>> with an example with values for var1 that illustrate the problem and what
>> the structure will look like after the restructure.****
>>
>> ** **
>>
>> Gene Maguin****
>>
>> ** **
>>
>> *From:* SPSSX(r) Discussion [mailto:

> SPSSX-L@.UGA

> ] *On Behalf
>> Of *Peter Spangler
>> *Sent:* Friday, March 15, 2013 8:52 PM
>> *To:*

> SPSSX-L@.UGA

>> *Subject:* Handling repeated cases****
>>
>> ** **
>>
>> Hi All,****
>>
>> ** **
>>
>> My data looks like this:****
>>
>> ** **
>>
>> UserID Var1 ****
>>
>> 1         string****
>>
>> 1         string****
>>
>> 1         string****
>>
>> 1         string****
>>
>> 1         string****
>>
>> ** **
>>
>> I'd like to select all "string" for each identical case and move them
>> into
>> columns, variables of their own to be associated with that case.****
>>
>> Any ideas?****
>>





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718803.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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: Handling repeated cases

David Marso
Administrator
Peter,
Actually, technically speaking it shouldn't be referred to as a scratch variable as there is an actual entity called a scratch variable in SPSS (very special creatures).   Maybe we can refer to it as a tosser?
I was seeking a way to be able to mass recode without actually knowing the values of the strings.
By creating a fake id (anything which does not exist in the data) and a string value which sorts before any of the actual strings the AUTORECODE forces the @ to precede any of the values.  By later creating another variable @@ (guaranteed to be at the end) I can use @ TO @@ in the recode and thereby ensure the new variable names are implicitly mapped (.->0, other->1).  It is by exploiting insights into the collating order of strings and the truly awesome INDEX feature of C2V (values ->variable names) that this sort of thing happens.
Back in the day prior to C2V one would have to create a VECTOR of strings, LOOP and XSAVE and it would be a truly fugly hack to get the original values into the variable names (doable but even more twisted than a Cirque Du Soleil contortionist act).
I am interested if anyone can come up with a native solution involving fewer steps (I mean no python).

Peter Spangler wrote
Wow! Thank you David. This is what I was looking for. Essentially I can
copy my IDs and Strings as is below and the scratch variable is to set
others to 0?

On Mon, Mar 18, 2013 at 9:34 AM, David Marso <[hidden email]> wrote:

> CASESTOVARS is the heavy lifter here but a bit of mojo in the middle
> crosses
> the bridge.
> * NOTE fake element @ at top with stand-in 0 id.
> I believe this is as slick as it gets (without hardcoding unknown variable
> names into the recode).
> --
> DATA LIST LIST/id (F2) S (A20).
> BEGIN DATA
> 0            @             /* note fake case here */
> 1            Music
> 1            Restaurants
> 1            Games
> 2            Music
> 2            Concerts
> 2            Animals
> END DATA.
>
> AUTORECODE S /INTO NS.
> CASESTOVARS /ID=ID / INDEX=S.
> COMPUTE @@=1.
> RECODE @ TO @@ (SYSMIS=0)(ELSE=1).
> SELECT IF ID NE 0.
> EXECUTE /* need this EXECUTE or else DELETE VARIABLES gives error */.
> DELETE VARIABLES @ @@.
> LIST.
>
> id Animals Concerts Games Music Restaurants
>
>  1    0        0      1     1        1
>  2    1        1      0     1        0
>
>
> Number of cases read:  2    Number of cases listed:  2
>
> Peter Spangler wrote
> > The goal is to restructure data such that the unique IDs can be analyzed
> > based on belonging to specific groups. Respondents have selected groups
> to
> > "Like" online. I see each group being a variable (column) coded 0/1,
> > yes/no. Respondents could then be analyzed for their odds of belonging to
> > group A given group B, Clustered, etc.
> >
> > Data example: I'd like to make Music, Restaurants and Games variables and
> > have ID 1 appear once. In this case ID 1 would be coded 1 for variables
> > Music, Restaurants, Games.
> >
> > *ID*  *Likes*
> > 1            Music
> > 1            Restaurants
> > 1            Games
> >
> >
> >
> >
> >
> > On Sat, Mar 16, 2013 at 7:25 AM, Maguin, Eugene <
>
> > emaguin@
>
> > > wrote:
> >
> >> One command: casestovars. If that doesn’t give you what you want, repost
> >> with an example with values for var1 that illustrate the problem and
> what
> >> the structure will look like after the restructure.****
> >>
> >> ** **
> >>
> >> Gene Maguin****
> >>
> >> ** **
> >>
> >> *From:* SPSSX(r) Discussion [mailto:
>
> > SPSSX-L@.UGA
>
> > ] *On Behalf
> >> Of *Peter Spangler
> >> *Sent:* Friday, March 15, 2013 8:52 PM
> >> *To:*
>
> > SPSSX-L@.UGA
>
> >> *Subject:* Handling repeated cases****
> >>
> >> ** **
> >>
> >> Hi All,****
> >>
> >> ** **
> >>
> >> My data looks like this:****
> >>
> >> ** **
> >>
> >> UserID Var1 ****
> >>
> >> 1         string****
> >>
> >> 1         string****
> >>
> >> 1         string****
> >>
> >> 1         string****
> >>
> >> 1         string****
> >>
> >> ** **
> >>
> >> I'd like to select all "string" for each identical case and move them
> >> into
> >> columns, variables of their own to be associated with that case.****
> >>
> >> Any ideas?****
> >>
>
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to
> email me.
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718803.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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
>
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Handling repeated cases

Peter Spangler
When I ran the syntax with your example everything worked perfectly. Same output. When I ran the syntax on my actual data the DATA LIST syntax was no problem to produce columns id and S. 
When running the second part I received error # 4825: 

COMPUTE @@ =1
RECODE @ TO @@ (SYSMIS=09) (ELSE=1)

ERROR #4825 IN COLUMN 13. TEXT: @@
THE FORM VARX TO VARY TO REFER TO A RANGE OF VARIABLES HAS BEEN USED INCORRECTLY
EXECUTION OF THIS COMMAND STOPS
SELECT IF ID NE 0.
EXECUTE/*NEED THIS EXECUTE OR ELSE DELETE VARIABLES GIVES ERROR */
DELETE VARIABLES @ @@.

On Mon, Mar 18, 2013 at 10:19 AM, David Marso <[hidden email]> wrote:
Peter,
Actually, technically speaking it *shouldn't be referred to as a scratch
variable* as there is an actual entity called a scratch variable in SPSS
(very special creatures).   Maybe we can refer to it as a tosser?
I was seeking a way to be able to mass recode without actually knowing the
values of the strings.
By creating a fake id (anything which does not exist in the data) and a
string value which sorts before any of the actual strings the AUTORECODE
forces the @ to precede any of the values.  By later creating another
variable @@ (guaranteed to be at the end) I can use @ TO @@ in the recode
and thereby ensure the new variable names are implicitly mapped (.->0,
other->1).  It is by exploiting insights into the collating order of strings
and the truly awesome INDEX feature of C2V (values ->variable names) that
this sort of thing happens.
Back in the day prior to C2V one would have to create a VECTOR of strings,
LOOP and XSAVE and it would be a truly fugly hack to get the original values
into the variable names (doable but even more twisted than a Cirque Du
Soleil contortionist act).
I am interested if anyone can come up with a *native* solution involving
fewer steps (I mean no python).


Peter Spangler wrote
> Wow! Thank you David. This is what I was looking for. Essentially I can
> copy my IDs and Strings as is below and the scratch variable is to set
> others to 0?
>
> On Mon, Mar 18, 2013 at 9:34 AM, David Marso &lt;

> david.marso@

> &gt; wrote:
>
>> CASESTOVARS is the heavy lifter here but a bit of mojo in the middle
>> crosses
>> the bridge.
>> * NOTE fake element @ at top with stand-in 0 id.
>> I believe this is as slick as it gets (without hardcoding unknown
>> variable
>> names into the recode).
>> --
>> DATA LIST LIST/id (F2) S (A20).
>> BEGIN DATA
>> 0            @             /* note fake case here */
>> 1            Music
>> 1            Restaurants
>> 1            Games
>> 2            Music
>> 2            Concerts
>> 2            Animals
>> END DATA.
>>
>> AUTORECODE S /INTO NS.
>> CASESTOVARS /ID=ID / INDEX=S.
>> COMPUTE @@=1.
>> RECODE @ TO @@ (SYSMIS=0)(ELSE=1).
>> SELECT IF ID NE 0.
>> EXECUTE /* need this EXECUTE or else DELETE VARIABLES gives error */.
>> DELETE VARIABLES @ @@.
>> LIST.
>>
>> id Animals Concerts Games Music Restaurants
>>
>>  1    0        0      1     1        1
>>  2    1        1      0     1        0
>>
>>
>> Number of cases read:  2    Number of cases listed:  2
>>
>> Peter Spangler wrote
>> > The goal is to restructure data such that the unique IDs can be
>> analyzed
>> > based on belonging to specific groups. Respondents have selected groups
>> to
>> > "Like" online. I see each group being a variable (column) coded 0/1,
>> > yes/no. Respondents could then be analyzed for their odds of belonging
>> to
>> > group A given group B, Clustered, etc.
>> >
>> > Data example: I'd like to make Music, Restaurants and Games variables
>> and
>> > have ID 1 appear once. In this case ID 1 would be coded 1 for variables
>> > Music, Restaurants, Games.
>> >
>> > *ID*  *Likes*
>> > 1            Music
>> > 1            Restaurants
>> > 1            Games
>> >
>> >
>> >
>> >
>> >
>> > On Sat, Mar 16, 2013 at 7:25 AM, Maguin, Eugene &lt;
>>
>> > emaguin@
>>
>> > &gt; wrote:
>> >
>> >> One command: casestovars. If that doesn’t give you what you want,
>> repost
>> >> with an example with values for var1 that illustrate the problem and
>> what
>> >> the structure will look like after the restructure.****
>> >>
>> >> ** **
>> >>
>> >> Gene Maguin****
>> >>
>> >> ** **
>> >>
>> >> *From:* SPSSX(r) Discussion [mailto:
>>
>> > SPSSX-L@.UGA
>>
>> > ] *On Behalf
>> >> Of *Peter Spangler
>> >> *Sent:* Friday, March 15, 2013 8:52 PM
>> >> *To:*
>>
>> > SPSSX-L@.UGA
>>
>> >> *Subject:* Handling repeated cases****
>> >>
>> >> ** **
>> >>
>> >> Hi All,****
>> >>
>> >> ** **
>> >>
>> >> My data looks like this:****
>> >>
>> >> ** **
>> >>
>> >> UserID Var1 ****
>> >>
>> >> 1         string****
>> >>
>> >> 1         string****
>> >>
>> >> 1         string****
>> >>
>> >> 1         string****
>> >>
>> >> 1         string****
>> >>
>> >> ** **
>> >>
>> >> I'd like to select all "string" for each identical case and move them
>> >> into
>> >> columns, variables of their own to be associated with that case.****
>> >>
>> >> Any ideas?****
>> >>
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> --
>> View this message in context:
>> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718803.html
>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718807.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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: Handling repeated cases

David Marso
Administrator
Let's see:  Your variable is not called S and you forgot to add the dummy case with @.
Must study the code, get the epiphany and then apply to your data.
Copy? Over and Out.
--
Peter Spangler wrote
When I ran the syntax with your example everything worked perfectly. Same
output. When I ran the syntax on my actual data the DATA LIST syntax was no
problem to produce columns id and S.
When running the second part I received error # 4825:

COMPUTE @@ =1
RECODE @ TO @@ (SYSMIS=09) (ELSE=1)

ERROR #4825 IN COLUMN 13. TEXT: @@
THE FORM VARX TO VARY TO REFER TO A RANGE OF VARIABLES HAS BEEN USED
INCORRECTLY
EXECUTION OF THIS COMMAND STOPS
SELECT IF ID NE 0.
EXECUTE/*NEED THIS EXECUTE OR ELSE DELETE VARIABLES GIVES ERROR */
DELETE VARIABLES @ @@.

On Mon, Mar 18, 2013 at 10:19 AM, David Marso <[hidden email]> wrote:

> Peter,
> Actually, technically speaking it *shouldn't be referred to as a scratch
> variable* as there is an actual entity called a scratch variable in SPSS
> (very special creatures).   Maybe we can refer to it as a tosser?
> I was seeking a way to be able to mass recode without actually knowing the
> values of the strings.
> By creating a fake id (anything which does not exist in the data) and a
> string value which sorts before any of the actual strings the AUTORECODE
> forces the @ to precede any of the values.  By later creating another
> variable @@ (guaranteed to be at the end) I can use @ TO @@ in the recode
> and thereby ensure the new variable names are implicitly mapped (.->0,
> other->1).  It is by exploiting insights into the collating order of
> strings
> and the truly awesome INDEX feature of C2V (values ->variable names) that
> this sort of thing happens.
> Back in the day prior to C2V one would have to create a VECTOR of strings,
> LOOP and XSAVE and it would be a truly fugly hack to get the original
> values
> into the variable names (doable but even more twisted than a Cirque Du
> Soleil contortionist act).
> I am interested if anyone can come up with a *native* solution involving
> fewer steps (I mean no python).
>
>
> Peter Spangler wrote
> > Wow! Thank you David. This is what I was looking for. Essentially I can
> > copy my IDs and Strings as is below and the scratch variable is to set
> > others to 0?
> >
> > On Mon, Mar 18, 2013 at 9:34 AM, David Marso <
>
> > david.marso@
>
> > > wrote:
> >
> >> CASESTOVARS is the heavy lifter here but a bit of mojo in the middle
> >> crosses
> >> the bridge.
> >> * NOTE fake element @ at top with stand-in 0 id.
> >> I believe this is as slick as it gets (without hardcoding unknown
> >> variable
> >> names into the recode).
> >> --
> >> DATA LIST LIST/id (F2) S (A20).
> >> BEGIN DATA
> >> 0            @             /* note fake case here */
> >> 1            Music
> >> 1            Restaurants
> >> 1            Games
> >> 2            Music
> >> 2            Concerts
> >> 2            Animals
> >> END DATA.
> >>
> >> AUTORECODE S /INTO NS.
> >> CASESTOVARS /ID=ID / INDEX=S.
> >> COMPUTE @@=1.
> >> RECODE @ TO @@ (SYSMIS=0)(ELSE=1).
> >> SELECT IF ID NE 0.
> >> EXECUTE /* need this EXECUTE or else DELETE VARIABLES gives error */.
> >> DELETE VARIABLES @ @@.
> >> LIST.
> >>
> >> id Animals Concerts Games Music Restaurants
> >>
> >>  1    0        0      1     1        1
> >>  2    1        1      0     1        0
> >>
> >>
> >> Number of cases read:  2    Number of cases listed:  2
> >>
> >> Peter Spangler wrote
> >> > The goal is to restructure data such that the unique IDs can be
> >> analyzed
> >> > based on belonging to specific groups. Respondents have selected
> groups
> >> to
> >> > "Like" online. I see each group being a variable (column) coded 0/1,
> >> > yes/no. Respondents could then be analyzed for their odds of belonging
> >> to
> >> > group A given group B, Clustered, etc.
> >> >
> >> > Data example: I'd like to make Music, Restaurants and Games variables
> >> and
> >> > have ID 1 appear once. In this case ID 1 would be coded 1 for
> variables
> >> > Music, Restaurants, Games.
> >> >
> >> > *ID*  *Likes*
> >> > 1            Music
> >> > 1            Restaurants
> >> > 1            Games
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > On Sat, Mar 16, 2013 at 7:25 AM, Maguin, Eugene <
> >>
> >> > emaguin@
> >>
> >> > > wrote:
> >> >
> >> >> One command: casestovars. If that doesn’t give you what you want,
> >> repost
> >> >> with an example with values for var1 that illustrate the problem and
> >> what
> >> >> the structure will look like after the restructure.****
> >> >>
> >> >> ** **
> >> >>
> >> >> Gene Maguin****
> >> >>
> >> >> ** **
> >> >>
> >> >> *From:* SPSSX(r) Discussion [mailto:
> >>
> >> > SPSSX-L@.UGA
> >>
> >> > ] *On Behalf
> >> >> Of *Peter Spangler
> >> >> *Sent:* Friday, March 15, 2013 8:52 PM
> >> >> *To:*
> >>
> >> > SPSSX-L@.UGA
> >>
> >> >> *Subject:* Handling repeated cases****
> >> >>
> >> >> ** **
> >> >>
> >> >> Hi All,****
> >> >>
> >> >> ** **
> >> >>
> >> >> My data looks like this:****
> >> >>
> >> >> ** **
> >> >>
> >> >> UserID Var1 ****
> >> >>
> >> >> 1         string****
> >> >>
> >> >> 1         string****
> >> >>
> >> >> 1         string****
> >> >>
> >> >> 1         string****
> >> >>
> >> >> 1         string****
> >> >>
> >> >> ** **
> >> >>
> >> >> I'd like to select all "string" for each identical case and move them
> >> >> into
> >> >> columns, variables of their own to be associated with that case.****
> >> >>
> >> >> Any ideas?****
> >> >>
> >>
> >>
> >>
> >>
> >>
> >> -----
> >> Please reply to the list and not to my personal email.
> >> Those desiring my consulting or training services please feel free to
> >> email me.
> >> --
> >> View this message in context:
> >>
> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718803.html
> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
> >>
> >> =====================
> >> To manage your subscription to SPSSX-L, send a message to
> >>
>
> > LISTSERV@.UGA
>
> >  (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
> >>
>
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to
> email me.
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718807.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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
>
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Handling repeated cases

Peter Spangler
The dummy case (0 @) appears at the top after BEGIN DATA. It also appears correctly in the created data file.
The epiphany that cases become variables and those ids without a given string become 0 and with become 1 is great. But these warnings indicate problems I'm unsure of.
 
Warnings:
The INDEX values for case 3 have occurred before in the cases with the same ID values
Execution of this command stops.

Text: @ Command: DELETE VARIABLES
An undefined variable name, or a scratch or system variable was specified in a variable list which accepts only standard variables.  Check spelling and verify the existence of this variable.
Execution of this command stops.





On Mon, Mar 18, 2013 at 11:28 AM, David Marso <[hidden email]> wrote:
Let's see:  Your variable is *not called S* and you forgot to add the *dummy
case with @*.
Must study the code, get the epiphany and then apply to your data.
Copy? Over and Out.
--

Peter Spangler wrote
> When I ran the syntax with your example everything worked perfectly. Same
> output. When I ran the syntax on my actual data the DATA LIST syntax was
> no
> problem to produce columns id and S.
> When running the second part I received error # 4825:
>
> COMPUTE @@ =1
> RECODE @ TO @@ (SYSMIS=09) (ELSE=1)
>
> ERROR #4825 IN COLUMN 13. TEXT: @@
> THE FORM VARX TO VARY TO REFER TO A RANGE OF VARIABLES HAS BEEN USED
> INCORRECTLY
> EXECUTION OF THIS COMMAND STOPS
> SELECT IF ID NE 0.
> EXECUTE/*NEED THIS EXECUTE OR ELSE DELETE VARIABLES GIVES ERROR */
> DELETE VARIABLES @ @@.
>
> On Mon, Mar 18, 2013 at 10:19 AM, David Marso &lt;

> david.marso@

> &gt; wrote:
>
>> Peter,
>> Actually, technically speaking it *shouldn't be referred to as a scratch
>> variable* as there is an actual entity called a scratch variable in SPSS
>> (very special creatures).   Maybe we can refer to it as a tosser?
>> I was seeking a way to be able to mass recode without actually knowing
>> the
>> values of the strings.
>> By creating a fake id (anything which does not exist in the data) and a
>> string value which sorts before any of the actual strings the AUTORECODE
>> forces the @ to precede any of the values.  By later creating another
>> variable @@ (guaranteed to be at the end) I can use @ TO @@ in the recode
>> and thereby ensure the new variable names are implicitly mapped (.->0,
>> other->1).  It is by exploiting insights into the collating order of
>> strings
>> and the truly awesome INDEX feature of C2V (values ->variable names) that
>> this sort of thing happens.
>> Back in the day prior to C2V one would have to create a VECTOR of
>> strings,
>> LOOP and XSAVE and it would be a truly fugly hack to get the original
>> values
>> into the variable names (doable but even more twisted than a Cirque Du
>> Soleil contortionist act).
>> I am interested if anyone can come up with a *native* solution involving
>> fewer steps (I mean no python).
>>
>>
>> Peter Spangler wrote
>> > Wow! Thank you David. This is what I was looking for. Essentially I can
>> > copy my IDs and Strings as is below and the scratch variable is to set
>> > others to 0?
>> >
>> > On Mon, Mar 18, 2013 at 9:34 AM, David Marso &lt;
>>
>> > david.marso@
>>
>> > &gt; wrote:
>> >
>> >> CASESTOVARS is the heavy lifter here but a bit of mojo in the middle
>> >> crosses
>> >> the bridge.
>> >> * NOTE fake element @ at top with stand-in 0 id.
>> >> I believe this is as slick as it gets (without hardcoding unknown
>> >> variable
>> >> names into the recode).
>> >> --
>> >> DATA LIST LIST/id (F2) S (A20).
>> >> BEGIN DATA
>> >> 0            @             /* note fake case here */
>> >> 1            Music
>> >> 1            Restaurants
>> >> 1            Games
>> >> 2            Music
>> >> 2            Concerts
>> >> 2            Animals
>> >> END DATA.
>> >>
>> >> AUTORECODE S /INTO NS.
>> >> CASESTOVARS /ID=ID / INDEX=S.
>> >> COMPUTE @@=1.
>> >> RECODE @ TO @@ (SYSMIS=0)(ELSE=1).
>> >> SELECT IF ID NE 0.
>> >> EXECUTE /* need this EXECUTE or else DELETE VARIABLES gives error */.
>> >> DELETE VARIABLES @ @@.
>> >> LIST.
>> >>
>> >> id Animals Concerts Games Music Restaurants
>> >>
>> >>  1    0        0      1     1        1
>> >>  2    1        1      0     1        0
>> >>
>> >>
>> >> Number of cases read:  2    Number of cases listed:  2
>> >>
>> >> Peter Spangler wrote
>> >> > The goal is to restructure data such that the unique IDs can be
>> >> analyzed
>> >> > based on belonging to specific groups. Respondents have selected
>> groups
>> >> to
>> >> > "Like" online. I see each group being a variable (column) coded 0/1,
>> >> > yes/no. Respondents could then be analyzed for their odds of
>> belonging
>> >> to
>> >> > group A given group B, Clustered, etc.
>> >> >
>> >> > Data example: I'd like to make Music, Restaurants and Games
>> variables
>> >> and
>> >> > have ID 1 appear once. In this case ID 1 would be coded 1 for
>> variables
>> >> > Music, Restaurants, Games.
>> >> >
>> >> > *ID*  *Likes*
>> >> > 1            Music
>> >> > 1            Restaurants
>> >> > 1            Games
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > On Sat, Mar 16, 2013 at 7:25 AM, Maguin, Eugene &lt;
>> >>
>> >> > emaguin@
>> >>
>> >> > &gt; wrote:
>> >> >
>> >> >> One command: casestovars. If that doesn’t give you what you want,
>> >> repost
>> >> >> with an example with values for var1 that illustrate the problem
>> and
>> >> what
>> >> >> the structure will look like after the restructure.****
>> >> >>
>> >> >> ** **
>> >> >>
>> >> >> Gene Maguin****
>> >> >>
>> >> >> ** **
>> >> >>
>> >> >> *From:* SPSSX(r) Discussion [mailto:
>> >>
>> >> > SPSSX-L@.UGA
>> >>
>> >> > ] *On Behalf
>> >> >> Of *Peter Spangler
>> >> >> *Sent:* Friday, March 15, 2013 8:52 PM
>> >> >> *To:*
>> >>
>> >> > SPSSX-L@.UGA
>> >>
>> >> >> *Subject:* Handling repeated cases****
>> >> >>
>> >> >> ** **
>> >> >>
>> >> >> Hi All,****
>> >> >>
>> >> >> ** **
>> >> >>
>> >> >> My data looks like this:****
>> >> >>
>> >> >> ** **
>> >> >>
>> >> >> UserID Var1 ****
>> >> >>
>> >> >> 1         string****
>> >> >>
>> >> >> 1         string****
>> >> >>
>> >> >> 1         string****
>> >> >>
>> >> >> 1         string****
>> >> >>
>> >> >> 1         string****
>> >> >>
>> >> >> ** **
>> >> >>
>> >> >> I'd like to select all "string" for each identical case and move
>> them
>> >> >> into
>> >> >> columns, variables of their own to be associated with that
>> case.****
>> >> >>
>> >> >> Any ideas?****
>> >> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> -----
>> >> Please reply to the list and not to my personal email.
>> >> Those desiring my consulting or training services please feel free to
>> >> email me.
>> >> --
>> >> View this message in context:
>> >>
>> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718803.html
>> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>> >>
>> >> =====================
>> >> To manage your subscription to SPSSX-L, send a message to
>> >>
>>
>> > LISTSERV@.UGA
>>
>> >  (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
>> >>
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> --
>> View this message in context:
>> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718807.html
>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718816.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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: Handling repeated cases

Peter Spangler
The repeated string values seem to prevent the second part of the syntax from functioning! When I use sample data with discrete string values per id (no duplicates) the syntax resumes working.

Can I SELECTCASES to delete cases where there are duplicate values. For example, delete cases 2 and 3.

case id string
   1   1 music
   2   1 music
   3   1 music



On Mon, Mar 18, 2013 at 12:08 PM, Peter Spangler <[hidden email]> wrote:
The dummy case (0 @) appears at the top after BEGIN DATA. It also appears correctly in the created data file.
The epiphany that cases become variables and those ids without a given string become 0 and with become 1 is great. But these warnings indicate problems I'm unsure of.
 
Warnings:
The INDEX values for case 3 have occurred before in the cases with the same ID values
Execution of this command stops.

Text: @ Command: DELETE VARIABLES
An undefined variable name, or a scratch or system variable was specified in a variable list which accepts only standard variables.  Check spelling and verify the existence of this variable.
Execution of this command stops.





On Mon, Mar 18, 2013 at 11:28 AM, David Marso <[hidden email]> wrote:
Let's see:  Your variable is *not called S* and you forgot to add the *dummy
case with @*.
Must study the code, get the epiphany and then apply to your data.
Copy? Over and Out.
--

Peter Spangler wrote
> When I ran the syntax with your example everything worked perfectly. Same
> output. When I ran the syntax on my actual data the DATA LIST syntax was
> no
> problem to produce columns id and S.
> When running the second part I received error # 4825:
>
> COMPUTE @@ =1
> RECODE @ TO @@ (SYSMIS=09) (ELSE=1)
>
> ERROR #4825 IN COLUMN 13. TEXT: @@
> THE FORM VARX TO VARY TO REFER TO A RANGE OF VARIABLES HAS BEEN USED
> INCORRECTLY
> EXECUTION OF THIS COMMAND STOPS
> SELECT IF ID NE 0.
> EXECUTE/*NEED THIS EXECUTE OR ELSE DELETE VARIABLES GIVES ERROR */
> DELETE VARIABLES @ @@.
>
> On Mon, Mar 18, 2013 at 10:19 AM, David Marso &lt;

> david.marso@

> &gt; wrote:
>
>> Peter,
>> Actually, technically speaking it *shouldn't be referred to as a scratch
>> variable* as there is an actual entity called a scratch variable in SPSS
>> (very special creatures).   Maybe we can refer to it as a tosser?
>> I was seeking a way to be able to mass recode without actually knowing
>> the
>> values of the strings.
>> By creating a fake id (anything which does not exist in the data) and a
>> string value which sorts before any of the actual strings the AUTORECODE
>> forces the @ to precede any of the values.  By later creating another
>> variable @@ (guaranteed to be at the end) I can use @ TO @@ in the recode
>> and thereby ensure the new variable names are implicitly mapped (.->0,
>> other->1).  It is by exploiting insights into the collating order of
>> strings
>> and the truly awesome INDEX feature of C2V (values ->variable names) that
>> this sort of thing happens.
>> Back in the day prior to C2V one would have to create a VECTOR of
>> strings,
>> LOOP and XSAVE and it would be a truly fugly hack to get the original
>> values
>> into the variable names (doable but even more twisted than a Cirque Du
>> Soleil contortionist act).
>> I am interested if anyone can come up with a *native* solution involving
>> fewer steps (I mean no python).
>>
>>
>> Peter Spangler wrote
>> > Wow! Thank you David. This is what I was looking for. Essentially I can
>> > copy my IDs and Strings as is below and the scratch variable is to set
>> > others to 0?
>> >
>> > On Mon, Mar 18, 2013 at 9:34 AM, David Marso &lt;
>>
>> > david.marso@
>>
>> > &gt; wrote:
>> >
>> >> CASESTOVARS is the heavy lifter here but a bit of mojo in the middle
>> >> crosses
>> >> the bridge.
>> >> * NOTE fake element @ at top with stand-in 0 id.
>> >> I believe this is as slick as it gets (without hardcoding unknown
>> >> variable
>> >> names into the recode).
>> >> --
>> >> DATA LIST LIST/id (F2) S (A20).
>> >> BEGIN DATA
>> >> 0            @             /* note fake case here */
>> >> 1            Music
>> >> 1            Restaurants
>> >> 1            Games
>> >> 2            Music
>> >> 2            Concerts
>> >> 2            Animals
>> >> END DATA.
>> >>
>> >> AUTORECODE S /INTO NS.
>> >> CASESTOVARS /ID=ID / INDEX=S.
>> >> COMPUTE @@=1.
>> >> RECODE @ TO @@ (SYSMIS=0)(ELSE=1).
>> >> SELECT IF ID NE 0.
>> >> EXECUTE /* need this EXECUTE or else DELETE VARIABLES gives error */.
>> >> DELETE VARIABLES @ @@.
>> >> LIST.
>> >>
>> >> id Animals Concerts Games Music Restaurants
>> >>
>> >>  1    0        0      1     1        1
>> >>  2    1        1      0     1        0
>> >>
>> >>
>> >> Number of cases read:  2    Number of cases listed:  2
>> >>
>> >> Peter Spangler wrote
>> >> > The goal is to restructure data such that the unique IDs can be
>> >> analyzed
>> >> > based on belonging to specific groups. Respondents have selected
>> groups
>> >> to
>> >> > "Like" online. I see each group being a variable (column) coded 0/1,
>> >> > yes/no. Respondents could then be analyzed for their odds of
>> belonging
>> >> to
>> >> > group A given group B, Clustered, etc.
>> >> >
>> >> > Data example: I'd like to make Music, Restaurants and Games
>> variables
>> >> and
>> >> > have ID 1 appear once. In this case ID 1 would be coded 1 for
>> variables
>> >> > Music, Restaurants, Games.
>> >> >
>> >> > *ID*  *Likes*
>> >> > 1            Music
>> >> > 1            Restaurants
>> >> > 1            Games
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > On Sat, Mar 16, 2013 at 7:25 AM, Maguin, Eugene &lt;
>> >>
>> >> > emaguin@
>> >>
>> >> > &gt; wrote:
>> >> >
>> >> >> One command: casestovars. If that doesn’t give you what you want,
>> >> repost
>> >> >> with an example with values for var1 that illustrate the problem
>> and
>> >> what
>> >> >> the structure will look like after the restructure.****
>> >> >>
>> >> >> ** **
>> >> >>
>> >> >> Gene Maguin****
>> >> >>
>> >> >> ** **
>> >> >>
>> >> >> *From:* SPSSX(r) Discussion [mailto:
>> >>
>> >> > SPSSX-L@.UGA
>> >>
>> >> > ] *On Behalf
>> >> >> Of *Peter Spangler
>> >> >> *Sent:* Friday, March 15, 2013 8:52 PM
>> >> >> *To:*
>> >>
>> >> > SPSSX-L@.UGA
>> >>
>> >> >> *Subject:* Handling repeated cases****
>> >> >>
>> >> >> ** **
>> >> >>
>> >> >> Hi All,****
>> >> >>
>> >> >> ** **
>> >> >>
>> >> >> My data looks like this:****
>> >> >>
>> >> >> ** **
>> >> >>
>> >> >> UserID Var1 ****
>> >> >>
>> >> >> 1         string****
>> >> >>
>> >> >> 1         string****
>> >> >>
>> >> >> 1         string****
>> >> >>
>> >> >> 1         string****
>> >> >>
>> >> >> 1         string****
>> >> >>
>> >> >> ** **
>> >> >>
>> >> >> I'd like to select all "string" for each identical case and move
>> them
>> >> >> into
>> >> >> columns, variables of their own to be associated with that
>> case.****
>> >> >>
>> >> >> Any ideas?****
>> >> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> -----
>> >> Please reply to the list and not to my personal email.
>> >> Those desiring my consulting or training services please feel free to
>> >> email me.
>> >> --
>> >> View this message in context:
>> >>
>> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718803.html
>> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>> >>
>> >> =====================
>> >> To manage your subscription to SPSSX-L, send a message to
>> >>
>>
>> > LISTSERV@.UGA
>>
>> >  (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
>> >>
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> --
>> View this message in context:
>> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718807.html
>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718816.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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: Handling repeated cases

David Marso
Administrator
In reply to this post by Peter Spangler
Well, It obviously works on my dummy data. Right.
So read it, master it, conform it to your data and enjoy the gift.
You need to get familiar with CasesToVars.  
1. Looks like perhaps the values for a case are not unique.
* Look at AGGREGATE for that.  
Obviously the CasesToVars underwent an epic fail because the data do not conform to the requirements of in their current state.
Aside from that?  You know myself and others on this list provide training and consulting services.  You might consider some of that from either myself or another.  Could possibly save you a lot of head banging and frustration!
---
Peter Spangler wrote
The dummy case (0 @) appears at the top after BEGIN DATA. It also appears
correctly in the created data file.
The epiphany that cases become variables and those ids without a given
string become 0 and with become 1 is great. But these warnings indicate
problems I'm unsure of.

*Warnings:*
The INDEX values for case 3 have occurred before in the cases with the same
ID values
Execution of this command stops.

Text: @ Command: DELETE VARIABLES
An undefined variable name, or a scratch or system variable was specified
in a variable list which accepts only standard variables.  Check spelling
and verify the existence of this variable.
Execution of this command stops.





On Mon, Mar 18, 2013 at 11:28 AM, David Marso <[hidden email]> wrote:

> Let's see:  Your variable is *not called S* and you forgot to add the
> *dummy
> case with @*.
> Must study the code, get the epiphany and then apply to your data.
> Copy? Over and Out.
> --
>
> Peter Spangler wrote
> > When I ran the syntax with your example everything worked perfectly. Same
> > output. When I ran the syntax on my actual data the DATA LIST syntax was
> > no
> > problem to produce columns id and S.
> > When running the second part I received error # 4825:
> >
> > COMPUTE @@ =1
> > RECODE @ TO @@ (SYSMIS=09) (ELSE=1)
> >
> > ERROR #4825 IN COLUMN 13. TEXT: @@
> > THE FORM VARX TO VARY TO REFER TO A RANGE OF VARIABLES HAS BEEN USED
> > INCORRECTLY
> > EXECUTION OF THIS COMMAND STOPS
> > SELECT IF ID NE 0.
> > EXECUTE/*NEED THIS EXECUTE OR ELSE DELETE VARIABLES GIVES ERROR */
> > DELETE VARIABLES @ @@.
> >
> > On Mon, Mar 18, 2013 at 10:19 AM, David Marso <
>
> > david.marso@
>
> > > wrote:
> >
> >> Peter,
> >> Actually, technically speaking it *shouldn't be referred to as a scratch
> >> variable* as there is an actual entity called a scratch variable in SPSS
> >> (very special creatures).   Maybe we can refer to it as a tosser?
> >> I was seeking a way to be able to mass recode without actually knowing
> >> the
> >> values of the strings.
> >> By creating a fake id (anything which does not exist in the data) and a
> >> string value which sorts before any of the actual strings the AUTORECODE
> >> forces the @ to precede any of the values.  By later creating another
> >> variable @@ (guaranteed to be at the end) I can use @ TO @@ in the
> recode
> >> and thereby ensure the new variable names are implicitly mapped (.->0,
> >> other->1).  It is by exploiting insights into the collating order of
> >> strings
> >> and the truly awesome INDEX feature of C2V (values ->variable names)
> that
> >> this sort of thing happens.
> >> Back in the day prior to C2V one would have to create a VECTOR of
> >> strings,
> >> LOOP and XSAVE and it would be a truly fugly hack to get the original
> >> values
> >> into the variable names (doable but even more twisted than a Cirque Du
> >> Soleil contortionist act).
> >> I am interested if anyone can come up with a *native* solution involving
> >> fewer steps (I mean no python).
> >>
> >>
> >> Peter Spangler wrote
> >> > Wow! Thank you David. This is what I was looking for. Essentially I
> can
> >> > copy my IDs and Strings as is below and the scratch variable is to set
> >> > others to 0?
> >> >
> >> > On Mon, Mar 18, 2013 at 9:34 AM, David Marso <
> >>
> >> > david.marso@
> >>
> >> > > wrote:
> >> >
> >> >> CASESTOVARS is the heavy lifter here but a bit of mojo in the middle
> >> >> crosses
> >> >> the bridge.
> >> >> * NOTE fake element @ at top with stand-in 0 id.
> >> >> I believe this is as slick as it gets (without hardcoding unknown
> >> >> variable
> >> >> names into the recode).
> >> >> --
> >> >> DATA LIST LIST/id (F2) S (A20).
> >> >> BEGIN DATA
> >> >> 0            @             /* note fake case here */
> >> >> 1            Music
> >> >> 1            Restaurants
> >> >> 1            Games
> >> >> 2            Music
> >> >> 2            Concerts
> >> >> 2            Animals
> >> >> END DATA.
> >> >>
> >> >> AUTORECODE S /INTO NS.
> >> >> CASESTOVARS /ID=ID / INDEX=S.
> >> >> COMPUTE @@=1.
> >> >> RECODE @ TO @@ (SYSMIS=0)(ELSE=1).
> >> >> SELECT IF ID NE 0.
> >> >> EXECUTE /* need this EXECUTE or else DELETE VARIABLES gives error */.
> >> >> DELETE VARIABLES @ @@.
> >> >> LIST.
> >> >>
> >> >> id Animals Concerts Games Music Restaurants
> >> >>
> >> >>  1    0        0      1     1        1
> >> >>  2    1        1      0     1        0
> >> >>
> >> >>
> >> >> Number of cases read:  2    Number of cases listed:  2
> >> >>
> >> >> Peter Spangler wrote
> >> >> > The goal is to restructure data such that the unique IDs can be
> >> >> analyzed
> >> >> > based on belonging to specific groups. Respondents have selected
> >> groups
> >> >> to
> >> >> > "Like" online. I see each group being a variable (column) coded
> 0/1,
> >> >> > yes/no. Respondents could then be analyzed for their odds of
> >> belonging
> >> >> to
> >> >> > group A given group B, Clustered, etc.
> >> >> >
> >> >> > Data example: I'd like to make Music, Restaurants and Games
> >> variables
> >> >> and
> >> >> > have ID 1 appear once. In this case ID 1 would be coded 1 for
> >> variables
> >> >> > Music, Restaurants, Games.
> >> >> >
> >> >> > *ID*  *Likes*
> >> >> > 1            Music
> >> >> > 1            Restaurants
> >> >> > 1            Games
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > On Sat, Mar 16, 2013 at 7:25 AM, Maguin, Eugene <
> >> >>
> >> >> > emaguin@
> >> >>
> >> >> > > wrote:
> >> >> >
> >> >> >> One command: casestovars. If that doesn’t give you what you want,
> >> >> repost
> >> >> >> with an example with values for var1 that illustrate the problem
> >> and
> >> >> what
> >> >> >> the structure will look like after the restructure.****
> >> >> >>
> >> >> >> ** **
> >> >> >>
> >> >> >> Gene Maguin****
> >> >> >>
> >> >> >> ** **
> >> >> >>
> >> >> >> *From:* SPSSX(r) Discussion [mailto:
> >> >>
> >> >> > SPSSX-L@.UGA
> >> >>
> >> >> > ] *On Behalf
> >> >> >> Of *Peter Spangler
> >> >> >> *Sent:* Friday, March 15, 2013 8:52 PM
> >> >> >> *To:*
> >> >>
> >> >> > SPSSX-L@.UGA
> >> >>
> >> >> >> *Subject:* Handling repeated cases****
> >> >> >>
> >> >> >> ** **
> >> >> >>
> >> >> >> Hi All,****
> >> >> >>
> >> >> >> ** **
> >> >> >>
> >> >> >> My data looks like this:****
> >> >> >>
> >> >> >> ** **
> >> >> >>
> >> >> >> UserID Var1 ****
> >> >> >>
> >> >> >> 1         string****
> >> >> >>
> >> >> >> 1         string****
> >> >> >>
> >> >> >> 1         string****
> >> >> >>
> >> >> >> 1         string****
> >> >> >>
> >> >> >> 1         string****
> >> >> >>
> >> >> >> ** **
> >> >> >>
> >> >> >> I'd like to select all "string" for each identical case and move
> >> them
> >> >> >> into
> >> >> >> columns, variables of their own to be associated with that
> >> case.****
> >> >> >>
> >> >> >> Any ideas?****
> >> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> -----
> >> >> Please reply to the list and not to my personal email.
> >> >> Those desiring my consulting or training services please feel free to
> >> >> email me.
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718803.html
> >> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
> >> >>
> >> >> =====================
> >> >> To manage your subscription to SPSSX-L, send a message to
> >> >>
> >>
> >> > LISTSERV@.UGA
> >>
> >> >  (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
> >> >>
> >>
> >>
> >>
> >>
> >>
> >> -----
> >> Please reply to the list and not to my personal email.
> >> Those desiring my consulting or training services please feel free to
> >> email me.
> >> --
> >> View this message in context:
> >>
> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718807.html
> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
> >>
> >> =====================
> >> To manage your subscription to SPSSX-L, send a message to
> >>
>
> > LISTSERV@.UGA
>
> >  (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
> >>
>
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to
> email me.
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718816.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> 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
>
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Handling repeated cases

Peter Spangler
I truly do appreciate the gift and will study the syntax and references. 
I think I'm on the path to solving this: Creates ID, (unique) string value, groupSize.
AGGREGATE
/OUTFILE='C:\Users\pspangler\Desktop\Marketplace/FB.AGG.sav'
/BREAK=ID S
/groupSize=N.

Removing groupSize variable leaves me with the data prepared for the remainder of the restructure syntax. Thanks again David!

On Mon, Mar 18, 2013 at 12:36 PM, David Marso <[hidden email]> wrote:
Well, It obviously works on my dummy data. Right.
So read it, master it, conform it to your data and enjoy the gift.
You need to get familiar with CasesToVars.
1. Looks like perhaps the values for a case are not unique.
* Look at AGGREGATE for that.
Obviously the CasesToVars underwent an epic fail because the data do not
conform to the requirements of in their current state.
Aside from that?  You know myself and others on this list provide training
and consulting services.  You might consider some of that from either myself
or another.  Could possibly save you a lot of head banging and frustration!
---

Peter Spangler wrote
> The dummy case (0 @) appears at the top after BEGIN DATA. It also appears
> correctly in the created data file.
> The epiphany that cases become variables and those ids without a given
> string become 0 and with become 1 is great. But these warnings indicate
> problems I'm unsure of.
>
> *Warnings:*
> The INDEX values for case 3 have occurred before in the cases with the
> same
> ID values
> Execution of this command stops.
>
> Text: @ Command: DELETE VARIABLES
> An undefined variable name, or a scratch or system variable was specified
> in a variable list which accepts only standard variables.  Check spelling
> and verify the existence of this variable.
> Execution of this command stops.
>
>
>
>
>
> On Mon, Mar 18, 2013 at 11:28 AM, David Marso &lt;

> david.marso@

> &gt; wrote:
>
>> Let's see:  Your variable is *not called S* and you forgot to add the
>> *dummy
>> case with @*.
>> Must study the code, get the epiphany and then apply to your data.
>> Copy? Over and Out.
>> --
>>
>> Peter Spangler wrote
>> > When I ran the syntax with your example everything worked perfectly.
>> Same
>> > output. When I ran the syntax on my actual data the DATA LIST syntax
>> was
>> > no
>> > problem to produce columns id and S.
>> > When running the second part I received error # 4825:
>> >
>> > COMPUTE @@ =1
>> > RECODE @ TO @@ (SYSMIS=09) (ELSE=1)
>> >
>> > ERROR #4825 IN COLUMN 13. TEXT: @@
>> > THE FORM VARX TO VARY TO REFER TO A RANGE OF VARIABLES HAS BEEN USED
>> > INCORRECTLY
>> > EXECUTION OF THIS COMMAND STOPS
>> > SELECT IF ID NE 0.
>> > EXECUTE/*NEED THIS EXECUTE OR ELSE DELETE VARIABLES GIVES ERROR */
>> > DELETE VARIABLES @ @@.
>> >
>> > On Mon, Mar 18, 2013 at 10:19 AM, David Marso &lt;
>>
>> > david.marso@
>>
>> > &gt; wrote:
>> >
>> >> Peter,
>> >> Actually, technically speaking it *shouldn't be referred to as a
>> scratch
>> >> variable* as there is an actual entity called a scratch variable in
>> SPSS
>> >> (very special creatures).   Maybe we can refer to it as a tosser?
>> >> I was seeking a way to be able to mass recode without actually knowing
>> >> the
>> >> values of the strings.
>> >> By creating a fake id (anything which does not exist in the data) and
>> a
>> >> string value which sorts before any of the actual strings the
>> AUTORECODE
>> >> forces the @ to precede any of the values.  By later creating another
>> >> variable @@ (guaranteed to be at the end) I can use @ TO @@ in the
>> recode
>> >> and thereby ensure the new variable names are implicitly mapped (.->0,
>> >> other->1).  It is by exploiting insights into the collating order of
>> >> strings
>> >> and the truly awesome INDEX feature of C2V (values ->variable names)
>> that
>> >> this sort of thing happens.
>> >> Back in the day prior to C2V one would have to create a VECTOR of
>> >> strings,
>> >> LOOP and XSAVE and it would be a truly fugly hack to get the original
>> >> values
>> >> into the variable names (doable but even more twisted than a Cirque Du
>> >> Soleil contortionist act).
>> >> I am interested if anyone can come up with a *native* solution
>> involving
>> >> fewer steps (I mean no python).
>> >>
>> >>
>> >> Peter Spangler wrote
>> >> > Wow! Thank you David. This is what I was looking for. Essentially I
>> can
>> >> > copy my IDs and Strings as is below and the scratch variable is to
>> set
>> >> > others to 0?
>> >> >
>> >> > On Mon, Mar 18, 2013 at 9:34 AM, David Marso &lt;
>> >>
>> >> > david.marso@
>> >>
>> >> > &gt; wrote:
>> >> >
>> >> >> CASESTOVARS is the heavy lifter here but a bit of mojo in the
>> middle
>> >> >> crosses
>> >> >> the bridge.
>> >> >> * NOTE fake element @ at top with stand-in 0 id.
>> >> >> I believe this is as slick as it gets (without hardcoding unknown
>> >> >> variable
>> >> >> names into the recode).
>> >> >> --
>> >> >> DATA LIST LIST/id (F2) S (A20).
>> >> >> BEGIN DATA
>> >> >> 0            @             /* note fake case here */
>> >> >> 1            Music
>> >> >> 1            Restaurants
>> >> >> 1            Games
>> >> >> 2            Music
>> >> >> 2            Concerts
>> >> >> 2            Animals
>> >> >> END DATA.
>> >> >>
>> >> >> AUTORECODE S /INTO NS.
>> >> >> CASESTOVARS /ID=ID / INDEX=S.
>> >> >> COMPUTE @@=1.
>> >> >> RECODE @ TO @@ (SYSMIS=0)(ELSE=1).
>> >> >> SELECT IF ID NE 0.
>> >> >> EXECUTE /* need this EXECUTE or else DELETE VARIABLES gives error
>> */.
>> >> >> DELETE VARIABLES @ @@.
>> >> >> LIST.
>> >> >>
>> >> >> id Animals Concerts Games Music Restaurants
>> >> >>
>> >> >>  1    0        0      1     1        1
>> >> >>  2    1        1      0     1        0
>> >> >>
>> >> >>
>> >> >> Number of cases read:  2    Number of cases listed:  2
>> >> >>
>> >> >> Peter Spangler wrote
>> >> >> > The goal is to restructure data such that the unique IDs can be
>> >> >> analyzed
>> >> >> > based on belonging to specific groups. Respondents have selected
>> >> groups
>> >> >> to
>> >> >> > "Like" online. I see each group being a variable (column) coded
>> 0/1,
>> >> >> > yes/no. Respondents could then be analyzed for their odds of
>> >> belonging
>> >> >> to
>> >> >> > group A given group B, Clustered, etc.
>> >> >> >
>> >> >> > Data example: I'd like to make Music, Restaurants and Games
>> >> variables
>> >> >> and
>> >> >> > have ID 1 appear once. In this case ID 1 would be coded 1 for
>> >> variables
>> >> >> > Music, Restaurants, Games.
>> >> >> >
>> >> >> > *ID*  *Likes*
>> >> >> > 1            Music
>> >> >> > 1            Restaurants
>> >> >> > 1            Games
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > On Sat, Mar 16, 2013 at 7:25 AM, Maguin, Eugene &lt;
>> >> >>
>> >> >> > emaguin@
>> >> >>
>> >> >> > &gt; wrote:
>> >> >> >
>> >> >> >> One command: casestovars. If that doesn’t give you what you
>> want,
>> >> >> repost
>> >> >> >> with an example with values for var1 that illustrate the problem
>> >> and
>> >> >> what
>> >> >> >> the structure will look like after the restructure.****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> Gene Maguin****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> *From:* SPSSX(r) Discussion [mailto:
>> >> >>
>> >> >> > SPSSX-L@.UGA
>> >> >>
>> >> >> > ] *On Behalf
>> >> >> >> Of *Peter Spangler
>> >> >> >> *Sent:* Friday, March 15, 2013 8:52 PM
>> >> >> >> *To:*
>> >> >>
>> >> >> > SPSSX-L@.UGA
>> >> >>
>> >> >> >> *Subject:* Handling repeated cases****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> Hi All,****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> My data looks like this:****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> UserID Var1 ****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> I'd like to select all "string" for each identical case and move
>> >> them
>> >> >> >> into
>> >> >> >> columns, variables of their own to be associated with that
>> >> case.****
>> >> >> >>
>> >> >> >> Any ideas?****
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> -----
>> >> >> Please reply to the list and not to my personal email.
>> >> >> Those desiring my consulting or training services please feel free
>> to
>> >> >> email me.
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718803.html
>> >> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>> >> >>
>> >> >> =====================
>> >> >> To manage your subscription to SPSSX-L, send a message to
>> >> >>
>> >>
>> >> > LISTSERV@.UGA
>> >>
>> >> >  (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
>> >> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> -----
>> >> Please reply to the list and not to my personal email.
>> >> Those desiring my consulting or training services please feel free to
>> >> email me.
>> >> --
>> >> View this message in context:
>> >>
>> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718807.html
>> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>> >>
>> >> =====================
>> >> To manage your subscription to SPSSX-L, send a message to
>> >>
>>
>> > LISTSERV@.UGA
>>
>> >  (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
>> >>
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> --
>> View this message in context:
>> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718816.html
>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718825.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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: Handling repeated cases

ViAnn Beadle

I’m still a bit unclear as to how you plan to use your profiles but it seems to me that you are throwing away a lot of information by turning a like category into a binary value. Depending upon how many persons I have,  I would think about leaving the data in long format and run a crosstab of string by id and then create a dataset from the pivot table of counts.

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Peter Spangler
Sent: Monday, March 18, 2013 4:35 PM
To: [hidden email]
Subject: Re: Handling repeated cases

 

I truly do appreciate the gift and will study the syntax and references. 

I think I'm on the path to solving this: Creates ID, (unique) string value, groupSize.

AGGREGATE

/OUTFILE='C:\Users\pspangler\Desktop\Marketplace/FB.AGG.sav'

/BREAK=ID S

/groupSize=N.

 

Removing groupSize variable leaves me with the data prepared for the remainder of the restructure syntax. Thanks again David!

 

On Mon, Mar 18, 2013 at 12:36 PM, David Marso <[hidden email]> wrote:

Well, It obviously works on my dummy data. Right.
So read it, master it, conform it to your data and enjoy the gift.
You need to get familiar with CasesToVars.
1. Looks like perhaps the values for a case are not unique.
* Look at AGGREGATE for that.
Obviously the CasesToVars underwent an epic fail because the data do not
conform to the requirements of in their current state.
Aside from that?  You know myself and others on this list provide training
and consulting services.  You might consider some of that from either myself
or another.  Could possibly save you a lot of head banging and frustration!
---

Peter Spangler wrote

> The dummy case (0 @) appears at the top after BEGIN DATA. It also appears


> correctly in the created data file.
> The epiphany that cases become variables and those ids without a given
> string become 0 and with become 1 is great. But these warnings indicate
> problems I'm unsure of.
>

> *Warnings:*

> The INDEX values for case 3 have occurred before in the cases with the
> same
> ID values
> Execution of this command stops.
>
> Text: @ Command: DELETE VARIABLES
> An undefined variable name, or a scratch or system variable was specified
> in a variable list which accepts only standard variables.  Check spelling
> and verify the existence of this variable.
> Execution of this command stops.
>
>
>
>
>

> On Mon, Mar 18, 2013 at 11:28 AM, David Marso &lt;


> david.marso@


> &gt; wrote:
>
>> Let's see:  Your variable is *not called S* and you forgot to add the
>> *dummy
>> case with @*.
>> Must study the code, get the epiphany and then apply to your data.
>> Copy? Over and Out.
>> --
>>
>> Peter Spangler wrote
>> > When I ran the syntax with your example everything worked perfectly.
>> Same
>> > output. When I ran the syntax on my actual data the DATA LIST syntax
>> was
>> > no
>> > problem to produce columns id and S.
>> > When running the second part I received error # 4825:
>> >
>> > COMPUTE @@ =1
>> > RECODE @ TO @@ (SYSMIS=09) (ELSE=1)
>> >
>> > ERROR #4825 IN COLUMN 13. TEXT: @@
>> > THE FORM VARX TO VARY TO REFER TO A RANGE OF VARIABLES HAS BEEN USED
>> > INCORRECTLY
>> > EXECUTION OF THIS COMMAND STOPS
>> > SELECT IF ID NE 0.
>> > EXECUTE/*NEED THIS EXECUTE OR ELSE DELETE VARIABLES GIVES ERROR */
>> > DELETE VARIABLES @ @@.
>> >
>> > On Mon, Mar 18, 2013 at 10:19 AM, David Marso &lt;
>>
>> >
[hidden email]
>>
>> > &gt; wrote:
>> >
>> >> Peter,
>> >> Actually, technically speaking it *shouldn't be referred to as a
>> scratch
>> >> variable* as there is an actual entity called a scratch variable in
>> SPSS
>> >> (very special creatures).   Maybe we can refer to it as a tosser?
>> >> I was seeking a way to be able to mass recode without actually knowing
>> >> the
>> >> values of the strings.
>> >> By creating a fake id (anything which does not exist in the data) and
>> a
>> >> string value which sorts before any of the actual strings the
>> AUTORECODE
>> >> forces the @ to precede any of the values.  By later creating another
>> >> variable @@ (guaranteed to be at the end) I can use @ TO @@ in the
>> recode
>> >> and thereby ensure the new variable names are implicitly mapped (.->0,
>> >> other->1).  It is by exploiting insights into the collating order of
>> >> strings
>> >> and the truly awesome INDEX feature of C2V (values ->variable names)
>> that
>> >> this sort of thing happens.
>> >> Back in the day prior to C2V one would have to create a VECTOR of
>> >> strings,
>> >> LOOP and XSAVE and it would be a truly fugly hack to get the original
>> >> values
>> >> into the variable names (doable but even more twisted than a Cirque Du
>> >> Soleil contortionist act).
>> >> I am interested if anyone can come up with a *native* solution
>> involving
>> >> fewer steps (I mean no python).
>> >>
>> >>
>> >> Peter Spangler wrote
>> >> > Wow! Thank you David. This is what I was looking for. Essentially I
>> can
>> >> > copy my IDs and Strings as is below and the scratch variable is to
>> set
>> >> > others to 0?
>> >> >
>> >> > On Mon, Mar 18, 2013 at 9:34 AM, David Marso &lt;
>> >>
>> >> >
[hidden email]
>> >>
>> >> > &gt; wrote:
>> >> >
>> >> >> CASESTOVARS is the heavy lifter here but a bit of mojo in the
>> middle
>> >> >> crosses
>> >> >> the bridge.
>> >> >> * NOTE fake element @ at top with stand-in 0 id.
>> >> >> I believe this is as slick as it gets (without hardcoding unknown
>> >> >> variable
>> >> >> names into the recode).
>> >> >> --
>> >> >> DATA LIST LIST/id (F2) S (A20).
>> >> >> BEGIN DATA
>> >> >> 0            @             /* note fake case here */
>> >> >> 1            Music
>> >> >> 1            Restaurants
>> >> >> 1            Games
>> >> >> 2            Music
>> >> >> 2            Concerts
>> >> >> 2            Animals
>> >> >> END DATA.
>> >> >>
>> >> >> AUTORECODE S /INTO NS.
>> >> >> CASESTOVARS /ID=ID / INDEX=S.
>> >> >> COMPUTE @@=1.
>> >> >> RECODE @ TO @@ (SYSMIS=0)(ELSE=1).
>> >> >> SELECT IF ID NE 0.
>> >> >> EXECUTE /* need this EXECUTE or else DELETE VARIABLES gives error
>> */.
>> >> >> DELETE VARIABLES @ @@.
>> >> >> LIST.
>> >> >>
>> >> >> id Animals Concerts Games Music Restaurants
>> >> >>
>> >> >>  1    0        0      1     1        1
>> >> >>  2    1        1      0     1        0
>> >> >>
>> >> >>
>> >> >> Number of cases read:  2    Number of cases listed:  2
>> >> >>
>> >> >> Peter Spangler wrote
>> >> >> > The goal is to restructure data such that the unique IDs can be
>> >> >> analyzed
>> >> >> > based on belonging to specific groups. Respondents have selected
>> >> groups
>> >> >> to
>> >> >> > "Like" online. I see each group being a variable (column) coded
>> 0/1,
>> >> >> > yes/no. Respondents could then be analyzed for their odds of
>> >> belonging
>> >> >> to
>> >> >> > group A given group B, Clustered, etc.
>> >> >> >
>> >> >> > Data example: I'd like to make Music, Restaurants and Games
>> >> variables
>> >> >> and
>> >> >> > have ID 1 appear once. In this case ID 1 would be coded 1 for
>> >> variables
>> >> >> > Music, Restaurants, Games.
>> >> >> >
>> >> >> > *ID*  *Likes*
>> >> >> > 1            Music
>> >> >> > 1            Restaurants
>> >> >> > 1            Games
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > On Sat, Mar 16, 2013 at 7:25 AM, Maguin, Eugene &lt;
>> >> >>
>> >> >> > emaguin@
>> >> >>
>> >> >> > &gt; wrote:
>> >> >> >
>> >> >> >> One command: casestovars. If that doesn’t give you what you
>> want,
>> >> >> repost
>> >> >> >> with an example with values for var1 that illustrate the problem
>> >> and
>> >> >> what
>> >> >> >> the structure will look like after the restructure.****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> Gene Maguin****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> *From:* SPSSX(r) Discussion [mailto:
>> >> >>
>> >> >> >
[hidden email]
>> >> >>
>> >> >> > ] *On Behalf
>> >> >> >> Of *Peter Spangler
>> >> >> >> *Sent:* Friday, March 15, 2013 8:52 PM
>> >> >> >> *To:*
>> >> >>
>> >> >> >
[hidden email]
>> >> >>
>> >> >> >> *Subject:* Handling repeated cases****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> Hi All,****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> My data looks like this:****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> UserID Var1 ****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> I'd like to select all "string" for each identical case and move
>> >> them
>> >> >> >> into
>> >> >> >> columns, variables of their own to be associated with that
>> >> case.****
>> >> >> >>
>> >> >> >> Any ideas?****
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> -----
>> >> >> Please reply to the list and not to my personal email.
>> >> >> Those desiring my consulting or training services please feel free
>> to
>> >> >> email me.
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>>
http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718803.html
>> >> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>> >> >>
>> >> >> =====================
>> >> >> 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
>> >> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> -----
>> >> Please reply to the list and not to my personal email.
>> >> Those desiring my consulting or training services please feel free to
>> >> email me.
>> >> --
>> >> View this message in context:
>> >>
>>
http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718807.html
>> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>> >>
>> >> =====================
>> >> 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
>> >>
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> --
>> View this message in context:
>>
http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718816.html
>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>
>> =====================
>> 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
>>





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
--

View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718825.html

Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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: Handling repeated cases

Peter Spangler
My interest began with a desire to restructure the data around categories of interest. The counts themselves do add to each users story. 

I am new to profile creation with this sort of data and welcome any suggestions.




On Mon, Mar 18, 2013 at 4:48 PM, ViAnn Beadle <[hidden email]> wrote:

I’m still a bit unclear as to how you plan to use your profiles but it seems to me that you are throwing away a lot of information by turning a like category into a binary value. Depending upon how many persons I have,  I would think about leaving the data in long format and run a crosstab of string by id and then create a dataset from the pivot table of counts.

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Peter Spangler
Sent: Monday, March 18, 2013 4:35 PM
To: [hidden email]


Subject: Re: Handling repeated cases

 

I truly do appreciate the gift and will study the syntax and references. 

I think I'm on the path to solving this: Creates ID, (unique) string value, groupSize.

AGGREGATE

/OUTFILE='C:\Users\pspangler\Desktop\Marketplace/FB.AGG.sav'

/BREAK=ID S

/groupSize=N.

 

Removing groupSize variable leaves me with the data prepared for the remainder of the restructure syntax. Thanks again David!

 

On Mon, Mar 18, 2013 at 12:36 PM, David Marso <[hidden email]> wrote:

Well, It obviously works on my dummy data. Right.
So read it, master it, conform it to your data and enjoy the gift.
You need to get familiar with CasesToVars.
1. Looks like perhaps the values for a case are not unique.
* Look at AGGREGATE for that.
Obviously the CasesToVars underwent an epic fail because the data do not
conform to the requirements of in their current state.
Aside from that?  You know myself and others on this list provide training
and consulting services.  You might consider some of that from either myself
or another.  Could possibly save you a lot of head banging and frustration!
---

Peter Spangler wrote

> The dummy case (0 @) appears at the top after BEGIN DATA. It also appears
> correctly in the created data file.
> The epiphany that cases become variables and those ids without a given
> string become 0 and with become 1 is great. But these warnings indicate
> problems I'm unsure of.
>

> *Warnings:*

> The INDEX values for case 3 have occurred before in the cases with the
> same
> ID values
> Execution of this command stops.
>
> Text: @ Command: DELETE VARIABLES
> An undefined variable name, or a scratch or system variable was specified
> in a variable list which accepts only standard variables.  Check spelling
> and verify the existence of this variable.
> Execution of this command stops.
>
>
>
>
>

> On Mon, Mar 18, 2013 at 11:28 AM, David Marso &lt;

> david.marso@


> &gt; wrote:
>
>> Let's see:  Your variable is *not called S* and you forgot to add the
>> *dummy
>> case with @*.
>> Must study the code, get the epiphany and then apply to your data.
>> Copy? Over and Out.
>> --
>>
>> Peter Spangler wrote
>> > When I ran the syntax with your example everything worked perfectly.
>> Same
>> > output. When I ran the syntax on my actual data the DATA LIST syntax
>> was
>> > no
>> > problem to produce columns id and S.
>> > When running the second part I received error # 4825:
>> >
>> > COMPUTE @@ =1
>> > RECODE @ TO @@ (SYSMIS=09) (ELSE=1)
>> >
>> > ERROR #4825 IN COLUMN 13. TEXT: @@
>> > THE FORM VARX TO VARY TO REFER TO A RANGE OF VARIABLES HAS BEEN USED
>> > INCORRECTLY
>> > EXECUTION OF THIS COMMAND STOPS
>> > SELECT IF ID NE 0.
>> > EXECUTE/*NEED THIS EXECUTE OR ELSE DELETE VARIABLES GIVES ERROR */
>> > DELETE VARIABLES @ @@.
>> >
>> > On Mon, Mar 18, 2013 at 10:19 AM, David Marso &lt;
>>
>> >
[hidden email]
>>
>> > &gt; wrote:
>> >
>> >> Peter,
>> >> Actually, technically speaking it *shouldn't be referred to as a
>> scratch
>> >> variable* as there is an actual entity called a scratch variable in
>> SPSS
>> >> (very special creatures).   Maybe we can refer to it as a tosser?
>> >> I was seeking a way to be able to mass recode without actually knowing
>> >> the
>> >> values of the strings.
>> >> By creating a fake id (anything which does not exist in the data) and
>> a
>> >> string value which sorts before any of the actual strings the
>> AUTORECODE
>> >> forces the @ to precede any of the values.  By later creating another
>> >> variable @@ (guaranteed to be at the end) I can use @ TO @@ in the
>> recode
>> >> and thereby ensure the new variable names are implicitly mapped (.->0,
>> >> other->1).  It is by exploiting insights into the collating order of
>> >> strings
>> >> and the truly awesome INDEX feature of C2V (values ->variable names)
>> that
>> >> this sort of thing happens.
>> >> Back in the day prior to C2V one would have to create a VECTOR of
>> >> strings,
>> >> LOOP and XSAVE and it would be a truly fugly hack to get the original
>> >> values
>> >> into the variable names (doable but even more twisted than a Cirque Du
>> >> Soleil contortionist act).
>> >> I am interested if anyone can come up with a *native* solution
>> involving
>> >> fewer steps (I mean no python).
>> >>
>> >>
>> >> Peter Spangler wrote
>> >> > Wow! Thank you David. This is what I was looking for. Essentially I
>> can
>> >> > copy my IDs and Strings as is below and the scratch variable is to
>> set
>> >> > others to 0?
>> >> >
>> >> > On Mon, Mar 18, 2013 at 9:34 AM, David Marso &lt;
>> >>
>> >> >
[hidden email]
>> >>
>> >> > &gt; wrote:
>> >> >
>> >> >> CASESTOVARS is the heavy lifter here but a bit of mojo in the
>> middle
>> >> >> crosses
>> >> >> the bridge.
>> >> >> * NOTE fake element @ at top with stand-in 0 id.
>> >> >> I believe this is as slick as it gets (without hardcoding unknown
>> >> >> variable
>> >> >> names into the recode).
>> >> >> --
>> >> >> DATA LIST LIST/id (F2) S (A20).
>> >> >> BEGIN DATA
>> >> >> 0            @             /* note fake case here */
>> >> >> 1            Music
>> >> >> 1            Restaurants
>> >> >> 1            Games
>> >> >> 2            Music
>> >> >> 2            Concerts
>> >> >> 2            Animals
>> >> >> END DATA.
>> >> >>
>> >> >> AUTORECODE S /INTO NS.
>> >> >> CASESTOVARS /ID=ID / INDEX=S.
>> >> >> COMPUTE @@=1.
>> >> >> RECODE @ TO @@ (SYSMIS=0)(ELSE=1).
>> >> >> SELECT IF ID NE 0.
>> >> >> EXECUTE /* need this EXECUTE or else DELETE VARIABLES gives error
>> */.
>> >> >> DELETE VARIABLES @ @@.
>> >> >> LIST.
>> >> >>
>> >> >> id Animals Concerts Games Music Restaurants
>> >> >>
>> >> >>  1    0        0      1     1        1
>> >> >>  2    1        1      0     1        0
>> >> >>
>> >> >>
>> >> >> Number of cases read:  2    Number of cases listed:  2
>> >> >>
>> >> >> Peter Spangler wrote
>> >> >> > The goal is to restructure data such that the unique IDs can be
>> >> >> analyzed
>> >> >> > based on belonging to specific groups. Respondents have selected
>> >> groups
>> >> >> to
>> >> >> > "Like" online. I see each group being a variable (column) coded
>> 0/1,
>> >> >> > yes/no. Respondents could then be analyzed for their odds of
>> >> belonging
>> >> >> to
>> >> >> > group A given group B, Clustered, etc.
>> >> >> >
>> >> >> > Data example: I'd like to make Music, Restaurants and Games
>> >> variables
>> >> >> and
>> >> >> > have ID 1 appear once. In this case ID 1 would be coded 1 for
>> >> variables
>> >> >> > Music, Restaurants, Games.
>> >> >> >
>> >> >> > *ID*  *Likes*
>> >> >> > 1            Music
>> >> >> > 1            Restaurants
>> >> >> > 1            Games
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > On Sat, Mar 16, 2013 at 7:25 AM, Maguin, Eugene &lt;
>> >> >>
>> >> >> > emaguin@
>> >> >>
>> >> >> > &gt; wrote:
>> >> >> >
>> >> >> >> One command: casestovars. If that doesn’t give you what you
>> want,
>> >> >> repost
>> >> >> >> with an example with values for var1 that illustrate the problem
>> >> and
>> >> >> what
>> >> >> >> the structure will look like after the restructure.****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> Gene Maguin****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> *From:* SPSSX(r) Discussion [mailto:
>> >> >>
>> >> >> >
[hidden email]
>> >> >>
>> >> >> > ] *On Behalf
>> >> >> >> Of *Peter Spangler
>> >> >> >> *Sent:* Friday, March 15, 2013 8:52 PM
>> >> >> >> *To:*
>> >> >>
>> >> >> >
[hidden email]
>> >> >>
>> >> >> >> *Subject:* Handling repeated cases****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> Hi All,****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> My data looks like this:****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> UserID Var1 ****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> I'd like to select all "string" for each identical case and move
>> >> them
>> >> >> >> into
>> >> >> >> columns, variables of their own to be associated with that
>> >> case.****
>> >> >> >>
>> >> >> >> Any ideas?****
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> -----
>> >> >> Please reply to the list and not to my personal email.
>> >> >> Those desiring my consulting or training services please feel free
>> to
>> >> >> email me.
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>>
http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718803.html
>> >> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>> >> >>
>> >> >> =====================
>> >> >> 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
>> >> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> -----
>> >> Please reply to the list and not to my personal email.
>> >> Those desiring my consulting or training services please feel free to
>> >> email me.
>> >> --
>> >> View this message in context:
>> >>
>>
http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718807.html
>> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>> >>
>> >> =====================
>> >> 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
>> >>
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> --
>> View this message in context:
>>
http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718816.html
>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>
>> =====================
>> 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
>>





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
--

View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718825.html

Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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: Handling repeated cases

Peter Spangler
Because I have predetermined categories of interests I began with the binary categorical level to evaluate the odds of membership among them.

For classification I would typically use a cluster analysis to build a decision tree. Is this the sort of classification -- association -- you would have in mind?

On Mon, Mar 18, 2013 at 5:44 PM, ViAnn Beadle <[hidden email]> wrote:

Data like this are typically used as input to recommendation engines using association rules (think Google search, Netflix recommendations, pop-in ads from Amazon, etc.).

 

The association engine (i.e., software) defines what it expects in the way of data. Typically pairs of items (in your scheme they are the crosses of all the nonempty likes within a person record) are aggregrated to build the network of linkages. I don’t know if a particular association engine considers multiple linkages from one person all that important in the building the model. I would think that saliency plays a role. If somebody likes a class of things more than often than somebody else, the propensity to like something recommended within that same class would be higher, wouldn’t it?

 

From: Peter Spangler [mailto:[hidden email]]
Sent: Monday, March 18, 2013 5:55 PM
To: ViAnn Beadle
Cc: [hidden email]


Subject: Re: Handling repeated cases

 

My interest began with a desire to restructure the data around categories of interest. The counts themselves do add to each users story. 

 

I am new to profile creation with this sort of data and welcome any suggestions.

 

 

 

 

On Mon, Mar 18, 2013 at 4:48 PM, ViAnn Beadle <[hidden email]> wrote:

I’m still a bit unclear as to how you plan to use your profiles but it seems to me that you are throwing away a lot of information by turning a like category into a binary value. Depending upon how many persons I have,  I would think about leaving the data in long format and run a crosstab of string by id and then create a dataset from the pivot table of counts.

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Peter Spangler
Sent: Monday, March 18, 2013 4:35 PM
To: [hidden email]


Subject: Re: Handling repeated cases

 

I truly do appreciate the gift and will study the syntax and references. 

I think I'm on the path to solving this: Creates ID, (unique) string value, groupSize.

AGGREGATE

/OUTFILE='C:\Users\pspangler\Desktop\Marketplace/FB.AGG.sav'

/BREAK=ID S

/groupSize=N.

 

Removing groupSize variable leaves me with the data prepared for the remainder of the restructure syntax. Thanks again David!

 

On Mon, Mar 18, 2013 at 12:36 PM, David Marso <[hidden email]> wrote:

Well, It obviously works on my dummy data. Right.
So read it, master it, conform it to your data and enjoy the gift.
You need to get familiar with CasesToVars.
1. Looks like perhaps the values for a case are not unique.
* Look at AGGREGATE for that.
Obviously the CasesToVars underwent an epic fail because the data do not
conform to the requirements of in their current state.
Aside from that?  You know myself and others on this list provide training
and consulting services.  You might consider some of that from either myself
or another.  Could possibly save you a lot of head banging and frustration!
---

Peter Spangler wrote

> The dummy case (0 @) appears at the top after BEGIN DATA. It also appears
> correctly in the created data file.
> The epiphany that cases become variables and those ids without a given
> string become 0 and with become 1 is great. But these warnings indicate
> problems I'm unsure of.
>

> *Warnings:*

> The INDEX values for case 3 have occurred before in the cases with the
> same
> ID values
> Execution of this command stops.
>
> Text: @ Command: DELETE VARIABLES
> An undefined variable name, or a scratch or system variable was specified
> in a variable list which accepts only standard variables.  Check spelling
> and verify the existence of this variable.
> Execution of this command stops.
>
>
>
>
>

> On Mon, Mar 18, 2013 at 11:28 AM, David Marso &lt;

> david.marso@


> &gt; wrote:
>
>> Let's see:  Your variable is *not called S* and you forgot to add the
>> *dummy
>> case with @*.
>> Must study the code, get the epiphany and then apply to your data.
>> Copy? Over and Out.
>> --
>>
>> Peter Spangler wrote
>> > When I ran the syntax with your example everything worked perfectly.
>> Same
>> > output. When I ran the syntax on my actual data the DATA LIST syntax
>> was
>> > no
>> > problem to produce columns id and S.
>> > When running the second part I received error # 4825:
>> >
>> > COMPUTE @@ =1
>> > RECODE @ TO @@ (SYSMIS=09) (ELSE=1)
>> >
>> > ERROR #4825 IN COLUMN 13. TEXT: @@
>> > THE FORM VARX TO VARY TO REFER TO A RANGE OF VARIABLES HAS BEEN USED
>> > INCORRECTLY
>> > EXECUTION OF THIS COMMAND STOPS
>> > SELECT IF ID NE 0.
>> > EXECUTE/*NEED THIS EXECUTE OR ELSE DELETE VARIABLES GIVES ERROR */
>> > DELETE VARIABLES @ @@.
>> >
>> > On Mon, Mar 18, 2013 at 10:19 AM, David Marso &lt;
>>
>> > [hidden email]
>>
>> > &gt; wrote:
>> >
>> >> Peter,
>> >> Actually, technically speaking it *shouldn't be referred to as a
>> scratch
>> >> variable* as there is an actual entity called a scratch variable in
>> SPSS
>> >> (very special creatures).   Maybe we can refer to it as a tosser?
>> >> I was seeking a way to be able to mass recode without actually knowing
>> >> the
>> >> values of the strings.
>> >> By creating a fake id (anything which does not exist in the data) and
>> a
>> >> string value which sorts before any of the actual strings the
>> AUTORECODE
>> >> forces the @ to precede any of the values.  By later creating another
>> >> variable @@ (guaranteed to be at the end) I can use @ TO @@ in the
>> recode
>> >> and thereby ensure the new variable names are implicitly mapped (.->0,
>> >> other->1).  It is by exploiting insights into the collating order of
>> >> strings
>> >> and the truly awesome INDEX feature of C2V (values ->variable names)
>> that
>> >> this sort of thing happens.
>> >> Back in the day prior to C2V one would have to create a VECTOR of
>> >> strings,
>> >> LOOP and XSAVE and it would be a truly fugly hack to get the original
>> >> values
>> >> into the variable names (doable but even more twisted than a Cirque Du
>> >> Soleil contortionist act).
>> >> I am interested if anyone can come up with a *native* solution
>> involving
>> >> fewer steps (I mean no python).
>> >>
>> >>
>> >> Peter Spangler wrote
>> >> > Wow! Thank you David. This is what I was looking for. Essentially I
>> can
>> >> > copy my IDs and Strings as is below and the scratch variable is to
>> set
>> >> > others to 0?
>> >> >
>> >> > On Mon, Mar 18, 2013 at 9:34 AM, David Marso &lt;
>> >>
>> >> > [hidden email]
>> >>
>> >> > &gt; wrote:
>> >> >
>> >> >> CASESTOVARS is the heavy lifter here but a bit of mojo in the
>> middle
>> >> >> crosses
>> >> >> the bridge.
>> >> >> * NOTE fake element @ at top with stand-in 0 id.
>> >> >> I believe this is as slick as it gets (without hardcoding unknown
>> >> >> variable
>> >> >> names into the recode).
>> >> >> --
>> >> >> DATA LIST LIST/id (F2) S (A20).
>> >> >> BEGIN DATA
>> >> >> 0            @             /* note fake case here */
>> >> >> 1            Music
>> >> >> 1            Restaurants
>> >> >> 1            Games
>> >> >> 2            Music
>> >> >> 2            Concerts
>> >> >> 2            Animals
>> >> >> END DATA.
>> >> >>
>> >> >> AUTORECODE S /INTO NS.
>> >> >> CASESTOVARS /ID=ID / INDEX=S.
>> >> >> COMPUTE @@=1.
>> >> >> RECODE @ TO @@ (SYSMIS=0)(ELSE=1).
>> >> >> SELECT IF ID NE 0.
>> >> >> EXECUTE /* need this EXECUTE or else DELETE VARIABLES gives error
>> */.
>> >> >> DELETE VARIABLES @ @@.
>> >> >> LIST.
>> >> >>
>> >> >> id Animals Concerts Games Music Restaurants
>> >> >>
>> >> >>  1    0        0      1     1        1
>> >> >>  2    1        1      0     1        0
>> >> >>
>> >> >>
>> >> >> Number of cases read:  2    Number of cases listed:  2
>> >> >>
>> >> >> Peter Spangler wrote
>> >> >> > The goal is to restructure data such that the unique IDs can be
>> >> >> analyzed
>> >> >> > based on belonging to specific groups. Respondents have selected
>> >> groups
>> >> >> to
>> >> >> > "Like" online. I see each group being a variable (column) coded
>> 0/1,
>> >> >> > yes/no. Respondents could then be analyzed for their odds of
>> >> belonging
>> >> >> to
>> >> >> > group A given group B, Clustered, etc.
>> >> >> >
>> >> >> > Data example: I'd like to make Music, Restaurants and Games
>> >> variables
>> >> >> and
>> >> >> > have ID 1 appear once. In this case ID 1 would be coded 1 for
>> >> variables
>> >> >> > Music, Restaurants, Games.
>> >> >> >
>> >> >> > *ID*  *Likes*
>> >> >> > 1            Music
>> >> >> > 1            Restaurants
>> >> >> > 1            Games
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > On Sat, Mar 16, 2013 at 7:25 AM, Maguin, Eugene &lt;
>> >> >>
>> >> >> > emaguin@
>> >> >>
>> >> >> > &gt; wrote:
>> >> >> >
>> >> >> >> One command: casestovars. If that doesn’t give you what you
>> want,
>> >> >> repost
>> >> >> >> with an example with values for var1 that illustrate the problem
>> >> and
>> >> >> what
>> >> >> >> the structure will look like after the restructure.****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> Gene Maguin****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> *From:* SPSSX(r) Discussion [mailto:
>> >> >>
>> >> >> > [hidden email]
>> >> >>
>> >> >> > ] *On Behalf
>> >> >> >> Of *Peter Spangler
>> >> >> >> *Sent:* Friday, March 15, 2013 8:52 PM
>> >> >> >> *To:*
>> >> >>
>> >> >> > [hidden email]
>> >> >>
>> >> >> >> *Subject:* Handling repeated cases****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> Hi All,****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> My data looks like this:****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> UserID Var1 ****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> 1         string****
>> >> >> >>
>> >> >> >> ** **
>> >> >> >>
>> >> >> >> I'd like to select all "string" for each identical case and move
>> >> them
>> >> >> >> into
>> >> >> >> columns, variables of their own to be associated with that
>> >> case.****
>> >> >> >>
>> >> >> >> Any ideas?****
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> -----
>> >> >> Please reply to the list and not to my personal email.
>> >> >> Those desiring my consulting or training services please feel free
>> to
>> >> >> email me.
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718803.html
>> >> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>> >> >>
>> >> >> =====================
>> >> >> 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
>> >> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> -----
>> >> Please reply to the list and not to my personal email.
>> >> Those desiring my consulting or training services please feel free to
>> >> email me.
>> >> --
>> >> View this message in context:
>> >>
>> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718807.html
>> >> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>> >>
>> >> =====================
>> >> 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
>> >>
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> --
>> View this message in context:
>> http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718816.html
>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>
>> =====================
>> 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
>>





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
--

View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Handling-repeated-cases-tp5718726p5718825.html

Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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