Restructure voter file

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

Restructure voter file

jdiez@magellanbr.com

I am trying to restructure a file that comes as a vertical file structure into a horizontal file structure.  Can anyone help?

 

DATA LIST FREE / voter_id election_date vote_type.

begin data

A001,11042012,A

A001,11042011,A

A001,11042011,P

B001,11042012,A

B001,11042010,P

end data.

list.

 

I would like my output file to look like this:

 

voter_id

ED_11042012

ED_11042011

ED_11042010

A001

A

A

P

B002

A

 

P

 

Thanks in advance.

Reply | Threaded
Open this post in threaded view
|

Re: Restructure voter file

Melissa Ives

CASESTOVARS

/ID = voter_id

/INDEX = election_date

/separator="_".

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of [hidden email]
Sent: Wednesday, January 09, 2013 11:11 AM
To: [hidden email]
Subject: [SPSSX-L] Restructure voter file

 

I am trying to restructure a file that comes as a vertical file structure into a horizontal file structure.  Can anyone help?

 

DATA LIST FREE / voter_id election_date vote_type.

begin data

A001,11042012,A

A001,11042011,A

A001,11042011,P

B001,11042012,A

B001,11042010,P

end data.

list.

 

I would like my output file to look like this:

 

voter_id

ED_11042012

ED_11042011

ED_11042010

A001

A

A

P

B002

A

 

P

 

Thanks in advance.

 



PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.
Reply | Threaded
Open this post in threaded view
|

Re: Restructure voter file

Bruce Weaver
Administrator
In reply to this post by jdiez@magellanbr.com
DATA LIST FREE / voter_id (A4) election_date (F8.0) vote_type (A1).
begin data
A001,11042012,A
A001,11042011,A
A001,11042010,P
B001,11042012,A
B001,11042010,P
end data.
list.

rename variables (vote_type = ED).

sort cases by voter_id election_date.
CASESTOVARS
  /ID=voter_id
  /INDEX=election_date
  /GROUPBY=VARIABLE
  /SEP="_".

SORT VARIABLES BY NAME (D).
LIST.

OUTPUT:

voter_id ED_11042012 ED_11042011 ED_11042010
 
A001     A           A           P
B001     A                       P
 
Number of cases read:  2    Number of cases listed:  2


jdiez@magellanbr.com wrote
I am trying to restructure a file that comes as a vertical file structure into a horizontal file structure.  Can anyone help?


DATA LIST FREE / voter_id election_date vote_type.

begin data

A001,11042012,A

A001,11042011,A

A001,11042011,P

B001,11042012,A

B001,11042010,P

end data.

list.



I would like my output file to look like this:


voter_id

ED_11042012

ED_11042011

ED_11042010

A001

A

A

P

B002

A



P




Thanks in advance.
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).