Restructuring Cases to Vars

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

erosenzweig
Posts: 5
Joined: Wed Aug 01, 2012 6:44 pm

Restructuring Cases to Vars

Postby erosenzweig » Sat May 16, 2015 4:25 am

Hi All –

I have a set of 398 stimuli, and had each of 500 people make a single judgment about each one of a random sample of 20 of those stimuli. So my dataset right now is in long-form, with 20 rows per person. I have a variable identifying which of one of the 398 stimuli that person was judging, and their single-number judgment of that stimuli.

So right now the datafile looks like 10000 rows of: (Sorry, I couldn't figure out how to put tabs in, so I put commas in to indicate column separators)

Participant ID, Stimuli, Rating
ID1, Stim1, 8
ID1, Stim142, 5
ID1, Stim3 , 4
… (17 more times for Participant ID1)

ID2, Stim2 , 7
ID2, Stim5 , 1
ID2, Stim90, 2
...

What I want to do is restructure my datafile so that I have 398 columns, one for each stimuli. I’d like to have one row per participant, and their numeric judgment for each of the 20 of those stimuli they evaluated. They would simply have missing data for each of the 376 stimuli (columns) that they did not see. So ideally it would look like this:

ParticipantID, Stim1, Stim2, Stim3, Stim4, Stim5…
ID1, 8, --, 4, --, --
ID2, --, 7, --, --, 1

Can anyone help me with what syntax I would use to do this? I believe it should involve CASES to VARS, but I am stumped about how to do it...

Many many thanks in advance for any guidance!
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Restructuring Cases to Vars

Postby GerineL » Mon May 18, 2015 8:29 am

it is probably easiest to just use the point and click menu for this, so you can see what you do, and then paste it to syntax. Look into "case to variable" option under restructure.
erosenzweig
Posts: 5
Joined: Wed Aug 01, 2012 6:44 pm

Re: Restructuring Cases to Vars

Postby erosenzweig » Mon May 18, 2015 3:29 pm

Hi Gerine --

But that is why I came here for help -- it is not clear to me how to use the point and click menu for this, as I am unclear what the identifier and index variables should be. Last night I started thinking that actually for what I am trying to do Transpose might be the right function. What I am looking for is for someone to read the description I have posted of what I need to do and give me guidance on how to do that, whether that is through the point and click menu or not.

Best,
Emily
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Restructuring Cases to Vars

Postby GerineL » Thu May 21, 2015 1:38 pm

data
restructure
cases into variables
Identifier: ID
Index: stimulus
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Restructuring Cases to Vars

Postby GerineL » Thu May 21, 2015 1:39 pm

just in case: If you are doing this because you want to compute a mean score over the 17 items, you can also do that using aggregate, that saves you the time in restructuring.
erosenzweig
Posts: 5
Joined: Wed Aug 01, 2012 6:44 pm

Re: Restructuring Cases to Vars

Postby erosenzweig » Thu May 21, 2015 1:57 pm

Thank you Gerine -- that did the trick! I really appreciate it!

Who is online

Users browsing this forum: No registered users and 1 guest

cron