« Return to Thread: Help restructuring a data file, TIA!

Re: Help restructuring a data file, TIA!

by GarcĂ­a-Granero :: Rate this Message:

Reply to Author | View in Thread

Hi:

This is quite close to what you want (you will have to concatenate after
Area and Loc to get A1, A2, B1, B2...)

DATA LIST LIST / AREA (A1) LOC (F8) CANDIDATE (A5) VOTES (F8).
BEGIN DATA
A 1 JON 2
A 1 MARY 3
A 1 PETER 4
A 2 MARY 3
A 2 PETER 8
B 1 JON 7
B 1 LOUIS 7
B 2 PETER 5
B 2 BILL 3
END DATA.

SORT CASES BY AREA LOC CANDIDATE .
CASESTOVARS
 /ID = AREA LOC
 /INDEX = CANDIDATE
 /GROUPBY = VARIABLE .

RECODE BILL JON LOUIS MARY PETER  (SYSMIS=0)  .
LIST .

HTH,
Marta GG

Gonzalo Kmaid wrote:

> I need some help restructuring a data file. I tried some options
> without luck, but I think it is a simple problem.
>
> Original data file looks something like this:
>
> AREA    LOC      CANDIDATE       VOTES
> A                1        JON               2
> A                1        MARY              3
> A                1        PETER             4
> A                2        MARY              3
> A                2        PETER             8
> B                1        JON              7
> B                1        LOUIS             7
> B                2        PETER             5
> B                2        BILL              3
> ..
>
> There are more than 60.000 files in the original data file.
>
> I would like a new data file like this:
>
>          VOTESJON         VOTESMARY        VOTESPETER
> VOTESLOUIS      VOTESBILL
> A1      2                 3                 4                 0
>                 0
> A2      0                 3                 8                 0
>                 0
> B1      7                 0                 0                 7
>                 0
> B2      0                 0                 5                 0
>                 3
> ...
>
> Each combination of AREA and LOC identifies one electoral district,
> and I want to get the number of votes per candidate within each
> district. Not all districts have the same candidates.
>
> I tried several combinations of aggregate and the restructuring
> wizard. No luck. Any help really appreciated. TIA!
>
> Gonzalo Kmaid
>
> *Gonzalo Kmaid
> *PhD Cornell University.
>
> ============================
> CIFRA
> Gonzalez, Raga y Asociados
> 707 06 77 (Telephone / Fax)
>
> www.cifra.com.uy
> <http://www.cifra.com.uy/>cifra@...
> Av. Brasil 2446/Ap 201
> Montevideo-Uruguay
> ============================
>


--
For miscellaneous SPSS related statistical stuff, visit:
http://gjyp.nl/marta/

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@... (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

 « Return to Thread: Help restructuring a data file, TIA!