user10265653
user10265653

Reputation:

Change rows to columns based on key ID's

So here's an example of what I have, and an explanation of what I am looking for. I can't seem to get the restructure function in SPSS to work properly, could be the wrong tool for the job. Any help would be appreciated. Thank you!



Any thoughts? Thank you!

Upvotes: 1

Views: 96

Answers (1)

eli-k
eli-k

Reputation: 11360

What you are missing is a key\index variable. Try this:

* first recreating your sample data.
data list list/ ID (f10) Car_Make  Car_Model (2a20).
begin data
999, "Subaru", "WRX"
867, "Volvo", "240"
999,"Acura", "TSX"
end data.

* now creating an index and restructuring.
sort cases by ID.
compute ind=1.
format ind(f2).
if $casenum>1 and ID=lag(ID) ind=lag(ind)+1.
casestovars /id=ID/index=ind/sep="_".

Upvotes: 1

Related Questions