Data manipulation question

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

Data manipulation question

Steve Peterson-5
Greetings,
 
I have received a data file .csv
that looks like this:
 
male, male, male, 9th, 9th, 9th (CR)
female, male, 9th, 10th (CR)
male, 11th (CR)
 
I need to arrange it this way:
male, 9th
male, 9th
male, 9th
female, 9th
.
.
.
male, 11th
 
Can anyone suggest a method?
TIA
 
 
 
 
Steve Peterson
ESC-20, School Support
210 370-5420 voice
210 370-5755 fax

***************************************************************************************************************************
The information contained in this transmission may contain privileged and confidential information and is intended only for the use of the person(s) named above. If you are not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender immediately by reply e-mail and destroy all copies of the original message.

****************************************************************************************************************************

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

AW: Data manipulation question

Georg Maubach
 Hi Steve,

I think it would be a good idea to but the values in variables like this

q1.1 q1.2 q1.3 q2.1 q2.2 q2.3

and then rearrange them with the command VARSTOCASES.

HTH

Best regards

Georg Maubach
Research Manager

-----Ursprüngliche Nachricht-----
Von: SPSSX(r) Discussion [mailto:[hidden email]] Im Auftrag von Steve Peterson
Gesendet: Montag, 12. November 2007 23:49
An: [hidden email]
Betreff: Data manipulation question

Greetings,

I have received a data file .csv
that looks like this:

male, male, male, 9th, 9th, 9th (CR)
female, male, 9th, 10th (CR)
male, 11th (CR)

I need to arrange it this way:
male, 9th
male, 9th
male, 9th
female, 9th
.
.
.
male, 11th

Can anyone suggest a method?
TIA




Steve Peterson
ESC-20, School Support
210 370-5420 voice
210 370-5755 fax

***************************************************************************************************************************
The information contained in this transmission may contain privileged and confidential information and is intended only for the use of the person(s) named above. If you are not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender immediately by reply e-mail and destroy all copies of the original message.

****************************************************************************************************************************

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

=====================
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: Data manipulation question

Frederic Villamayor Forcada
In reply to this post by Steve Peterson-5
Steve,

I think this syntax should work.

DATA LIST FREE (", ") /aaa (A8).
BEGIN DATA
male, male, male, 9th, 9th, 9th
female, male, 9th, 10th
male, 11th
END DATA.

COMPUTE bbb=ANY(aaa,"male", "female").
COMPUTE ccc=$CASENUM.
RANK
  VARIABLES=ccc  (A) BY BBB  /RANK /PRINT=YES
  /TIES=MEAN .

EXECUTE.

TEMPORARY.
SELECT IF BBB .
XSAVE OUTFILE='Yourpath\sex.sav'
 /RENAME (aaa Rccc=sex id)
  /KEEP id sex /COMPRESSED.
FILTER OFF.

EXECUTE.

COMPUTE BBB=not BBB.

EXECUTE.

TEMPORARY.
SELECT IF BBB .
XSAVE OUTFILE='Yourpath\ordinal.sav'
 /RENAME (aaa Rccc=ordinal id)
  /KEEP id ordinal /COMPRESSED.
FILTER OFF.

EXECUTE.

MATCH FILES
 FILE ='Yourpath\sex.sav'
 /FILE ='Yourpath\ordinal.sav'
 /BY id
 /KEEP sex ordinal.



Greetings


Frederic


Frederic Villamayor, BS
Researcher/Study Manager
Biostatistics Unit
Juan de Sada, 32
08028 Barcelona
Tel    +34 935093236
Fax   +34 934112764
[hidden email]
http://www.ferrergrupo.com 

Este mensaje, y en su caso, cualquier fichero anexo al mismo, puede
contener información confidencial, siendo para uso exclusivo del
destinatario, quedando prohibida su divulgación, copia o distribución a
terceros sin la autorización expresa del remitente. Si Vd. ha recibido
este mensaje erróneamente, se ruega lo notifique al remitente y proceda a
su borrado. Gracias por su colaboración.

This message and its annexed files may contain confidential information
which is exclusively for the use of the addressee. It is strictly
forbidden to distribute copies to third parties without the explicit
permission of the sender. If you receive this message by mistake, please
notify it to the sender and make sure to delete it. Thank you for your
kind cooperation.




Steve Peterson <[hidden email]>
Enviado por: "SPSSX(r) Discussion" <[hidden email]>
12/11/2007 23:49
Por favor, responda a
Steve Peterson <[hidden email]>


Para
[hidden email]
cc

Asunto
[SPSSX-L] Data manipulation question






Greetings,
 
I have received a data file .csv
that looks like this:
 
male, male, male, 9th, 9th, 9th (CR)
female, male, 9th, 10th (CR)
male, 11th (CR)
 
I need to arrange it this way:
male, 9th
male, 9th
male, 9th
female, 9th
.
.
.
male, 11th
 
Can anyone suggest a method?
TIA
 
 
 
 
Steve Peterson
ESC-20, School Support
210 370-5420 voice
210 370-5755 fax

***************************************************************************************************************************
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or
agent responsible for delivering this message to the intended recipient,
any review, dissemination, distribution or duplication of this
communication is strictly prohibited. If you are not the intended
recipient, please contact the sender immediately by reply e-mail and
destroy all copies of the original message.

****************************************************************************************************************************

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

====================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: Data manipulation question

vlad simion
Hi,

try this:

get data  /type = txt
 /file = 'your path\book1.csv'
 /delcase = line
 /delimiters = ","
 /arrangement = delimited
 /firstcase = 2
 /importcase = all
 /variables =
 g1 a6
 g2 a6
 g3 a6
 gr1 a6
 gr2 a6
 gr3 a6 .
cache.
execute.
dataset name dataset2 window=front.

do repeat q=g1 to gr3.
compute q=ltrim(rtrim(q)).
end repeat.
exe.

varstocases /id = id
 /make trans1 from g1 g2 g3
 /make trans2 from gr1 gr2 gr3
 /index = index1(3)
 /keep =
 /null = keep.

Hth,
Vlad

On Nov 13, 2007 10:18 AM, Frederic Villamayor Forcada <
[hidden email]> wrote:

> Steve,
>
> I think this syntax should work.
>
> DATA LIST FREE (", ") /aaa (A8).
> BEGIN DATA
> male, male, male, 9th, 9th, 9th
> female, male, 9th, 10th
> male, 11th
> END DATA.
>
> COMPUTE bbb=ANY(aaa,"male", "female").
> COMPUTE ccc=$CASENUM.
> RANK
>  VARIABLES=ccc  (A) BY BBB  /RANK /PRINT=YES
>  /TIES=MEAN .
>
> EXECUTE.
>
> TEMPORARY.
> SELECT IF BBB .
> XSAVE OUTFILE='Yourpath\sex.sav'
>  /RENAME (aaa Rccc=sex id)
>  /KEEP id sex /COMPRESSED.
> FILTER OFF.
>
> EXECUTE.
>
> COMPUTE BBB=not BBB.
>
> EXECUTE.
>
> TEMPORARY.
> SELECT IF BBB .
> XSAVE OUTFILE='Yourpath\ordinal.sav'
>  /RENAME (aaa Rccc=ordinal id)
>  /KEEP id ordinal /COMPRESSED.
> FILTER OFF.
>
> EXECUTE.
>
> MATCH FILES
>  FILE ='Yourpath\sex.sav'
>  /FILE ='Yourpath\ordinal.sav'
>  /BY id
>  /KEEP sex ordinal.
>
>
>
> Greetings
>
>
> Frederic
>
>
> Frederic Villamayor, BS
> Researcher/Study Manager
> Biostatistics Unit
> Juan de Sada, 32
> 08028 Barcelona
> Tel    +34 935093236
> Fax   +34 934112764
> [hidden email]
> http://www.ferrergrupo.com
>
> Este mensaje, y en su caso, cualquier fichero anexo al mismo, puede
> contener información confidencial, siendo para uso exclusivo del
> destinatario, quedando prohibida su divulgación, copia o distribución a
> terceros sin la autorización expresa del remitente. Si Vd. ha recibido
> este mensaje erróneamente, se ruega lo notifique al remitente y proceda a
> su borrado. Gracias por su colaboración.
>
> This message and its annexed files may contain confidential information
> which is exclusively for the use of the addressee. It is strictly
> forbidden to distribute copies to third parties without the explicit
> permission of the sender. If you receive this message by mistake, please
> notify it to the sender and make sure to delete it. Thank you for your
> kind cooperation.
>
>
>
>
> Steve Peterson <[hidden email]>
> Enviado por: "SPSSX(r) Discussion" <[hidden email]>
> 12/11/2007 23:49
> Por favor, responda a
> Steve Peterson <[hidden email]>
>
>
> Para
> [hidden email]
> cc
>
> Asunto
> [SPSSX-L] Data manipulation question
>
>
>
>
>
>
> Greetings,
>
> I have received a data file .csv
> that looks like this:
>
> male, male, male, 9th, 9th, 9th (CR)
> female, male, 9th, 10th (CR)
> male, 11th (CR)
>
> I need to arrange it this way:
> male, 9th
> male, 9th
> male, 9th
> female, 9th
> .
> .
> .
> male, 11th
>
> Can anyone suggest a method?
> TIA
>
>
>
>
> Steve Peterson
> ESC-20, School Support
> 210 370-5420 voice
> 210 370-5755 fax
>
>
> ***************************************************************************************************************************
> The information contained in this transmission may contain privileged and
> confidential information and is intended only for the use of the person(s)
> named above. If you are not the intended recipient, or an employee or
> agent responsible for delivering this message to the intended recipient,
> any review, dissemination, distribution or duplication of this
> communication is strictly prohibited. If you are not the intended
> recipient, please contact the sender immediately by reply e-mail and
> destroy all copies of the original message.
>
>
> ****************************************************************************************************************************
>
> ====================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
>
> 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
>



--
Vlad Simion
Data Analyst
Tel:      +40 0751945296

====================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: Data manipulation question

hillel vardi
In reply to this post by Steve Peterson-5
Shalom

Here is a very simple syntax that will do what you need.
It assume that in every line there is the same number of gender data and
grade data,  and that all the gender data come first .


DATA LIST list  (", ") /a1 to a10 (10A8).
BEGIN DATA
male, male, male, 9th, 9th, 9th
female, male, 9th, 10th
male, 11th
END DATA.
vector      aa=a1 to a10 .
string       sex grade(a8) .
count      nn=a1 to a10 ("male", "female").

loop         i=1 to nn  .
compute   sex= aa(i)   .
compute   grade= aa(nn+i)   .
print        /   i  sex grade .
xsave       outfile="tmp.sav" / keep=sex grade   .
end  loop.
execute .
get           file="tmp.sav"  .

Hillel Vardi
BGU




Steve Peterson wrote:

> Greetings,
>
> I have received a data file .csv
> that looks like this:
>
> male, male, male, 9th, 9th, 9th (CR)
> female, male, 9th, 10th (CR)
> male, 11th (CR)
>
> I need to arrange it this way:
> male, 9th
> male, 9th
> male, 9th
> female, 9th
> .
> .
> .
> male, 11th
>
> Can anyone suggest a method?
> TIA
>
>
>
>
> Steve Peterson
> ESC-20, School Support
> 210 370-5420 voice
> 210 370-5755 fax
>
> ***************************************************************************************************************************
> The information contained in this transmission may contain privileged and confidential information and is intended only for the use of the person(s) named above. If you are not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender immediately by reply e-mail and destroy all copies of the original message.
>
> ****************************************************************************************************************************
>
> ===================
> 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
>
>

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