Data file restructure

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

Data file restructure

Ruben Geert van den Berg
Dear all,
 
I've a dataset like this:
 
DATA LIST FREE/ID Var.
BEGIN DATA
1 1
1 2
1 3
2 4
2 5
2 6
3 7
3 8
3 9
END DATA.
 
I'd like to restructure it to this:
 
data list free/var1 var2 var3.
begin data.
1 4 7
2 5 8
3 6 9
end data.

I think it should be possible with CASESTOVARS:
 
casestovars
/ID=ID
/index=Var.

However, this doesn't yield the desired result. I apologize for my clumsiness with casestovars but could anybody please show how it should be done?
 
TIA!
 
Ruben van den Berg

 





What can you do with the new Windows Live? Find out
Reply | Threaded
Open this post in threaded view
|

Re: Data file restructure

Joost van Ginkel
Dear Ruben,
 
I think it should be:
 
DATA LIST FREE/ID Var.
BEGIN DATA
1 1
2 2
3 3
1 4
2 5
3 6
1 7
2 8
3 9
END DATA.
 
The way you did it, case 1 probably got values of 1, 2, and 3, case 2 got values of 4,5, and 5, and so on. Goodluck!
 
Joost van Ginkel
 

Joost R. Van Ginkel, PhD
Leiden University
Faculty of Social and Behavioural Sciences
Data Theory Group
PO Box 9555
2300 RB Leiden
The Netherlands
Tel: +31-(0)71-527 3620
Fax: +31-(0)71-527 1721

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ruben van den Berg
Sent: 08 September 2009 11:25
To: [hidden email]
Subject: Data file restructure

Dear all,
 
I've a dataset like this:
 
DATA LIST FREE/ID Var.
BEGIN DATA
1 1
1 2
1 3
2 4
2 5
2 6
3 7
3 8
3 9
END DATA.
 
I'd like to restructure it to this:
 
data list free/var1 var2 var3.
begin data.
1 4 7
2 5 8
3 6 9
end data.

I think it should be possible with CASESTOVARS:
 
casestovars
/ID=ID
/index=Var.

However, this doesn't yield the desired result. I apologize for my clumsiness with casestovars but could anybody please show how it should be done?
 
TIA!
 
Ruben van den Berg

 





What can you do with the new Windows Live? Find out

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

This email and any files transmitted with it are confidential and

intended solely for the use of the individual or entity to whom they

are addressed. If you have received this email in error please notify

the system manager.

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

 

Reply | Threaded
Open this post in threaded view
|

Re: Data file restructure

Spousta Jan
In reply to this post by Ruben Geert van den Berg
Hi Ruben, try this:
 

DATA LIST FREE/ID Var.

BEGIN DATA

1 1

1 2

1 3

2 4

2 5

2 6

3 7

3 8

3 9

END DATA.

 

compute aux = 1.

form aux (f2) .

if ($casenum > 1 and ID = lag(ID) ) aux = lag(aux ) + 1 .

exe.

SORT CASES BY AUX ID.

CASESTOVARS

/ID = aux

/INDEX = ID

/GROUPBY = VARIABLE .

 

Jan



From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ruben van den Berg
Sent: Tuesday, September 08, 2009 11:25 AM
To: [hidden email]
Subject: Data file restructure

Dear all,
 
I've a dataset like this:
 
DATA LIST FREE/ID Var.
BEGIN DATA
1 1
1 2
1 3
2 4
2 5
2 6
3 7
3 8
3 9
END DATA.
 
I'd like to restructure it to this:
 
data list free/var1 var2 var3.
begin data.
1 4 7
2 5 8
3 6 9
end data.

I think it should be possible with CASESTOVARS:
 
casestovars
/ID=ID
/index=Var.

However, this doesn't yield the desired result. I apologize for my clumsiness with casestovars but could anybody please show how it should be done?
 
TIA!
 
Ruben van den Berg

 





What can you do with the new Windows Live? Find out  

_____________

Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem.

P Jste si jisti, že opravdu potřebujete vytisknout tuto zprávu a/nebo její přílohy? Myslete na přírodu.

 


This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission.

 

P Are you sure that you really need a print version of this message and/or its attachments? Think about nature.

-.- --
Reply | Threaded
Open this post in threaded view
|

Re: Data file restructure

Ruben Geert van den Berg
Thanks very much, that is exactly what I was looking for!
 
Ruben



 



 

Date: Tue, 8 Sep 2009 11:39:09 +0200
From: [hidden email]
Subject: Re: Data file restructure
To: [hidden email]

Hi Ruben, try this:
 
DATA LIST FREE/ID Var.
BEGIN DATA
1 1
1 2
1 3
2 4
2 5
2 6
3 7
3 8
3 9
END DATA.
 
compute aux = 1.
form aux (f2) .
if ($casenum > 1 and ID = lag(ID) ) aux = lag(aux ) + 1 .
exe.
SORT CASES BY AUX ID.
CASESTOVARS
/ID = aux
/INDEX = ID
/GROUPBY = VARIABLE .
 
Jan


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ruben van den Berg
Sent: Tuesday, September 08, 2009 11:25 AM
To: [hidden email]
Subject: Data file restructure

Dear all,
 
I've a dataset like this:
 
DATA LIST FREE/ID Var.
BEGIN DATA
1 1
1 2
1 3
2 4
2 5
2 6
3 7
3 8
3 9
END DATA.
 
I'd like to restructure it to this:
 
data list free/var1 var2 var3.
begin data.
1 4 7
2 5 8
3 6 9
end data.

I think it should be possible with CASESTOVARS:
 
casestovars
/ID=ID
/index=Var.

However, this doesn't yield the desired result. I apologize for my clumsiness with casestovars but could anybody please show how it should be done?
 
TIA!
 
Ruben van den Berg

 





What can you do with the new Windows Live? Find out  

_____________

Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem.

P Jste si jisti, že opravdu potřebujete vytisknout tuto zprávu a/nebo její přílohy? Myslete na přírodu.

 


This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission.

 

P Are you sure that you really need a print version of this message and/or its attachments? Think about nature.

-.- --


See all the ways you can stay connected to friends and family
Reply | Threaded
Open this post in threaded view
|

Subtracting dates with missing values

Jill Stoltzfus
In reply to this post by Spousta Jan

Hello everyone. A colleague wants to subtract dates, but she's having difficulty doing so because there are some missing values. Any advice would be much appreciated.

Thanks.

Jill

Reply | Threaded
Open this post in threaded view
|

Re: Subtracting dates with missing values

Bruce Weaver
Administrator
Jill Stoltzfus wrote
Hello everyone. A colleague wants to subtract dates, but she's having difficulty doing so because there are some missing values. Any advice would be much appreciated.

Thanks.
Jill
For any computation, if one of the elements is missing, the result will also be missing.  So the only way around this, I think, is to impute some date wherever a date is missing.  Whether it is possible (and reasonable) to do so is something your colleague will have to judge.

--
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/).
Reply | Threaded
Open this post in threaded view
|

Re: Subtracting dates with missing values

Jill Stoltzfus

Thanks, Bruce. I think I figured out how to do this.

Jill


--- On Tue, 9/8/09, Bruce Weaver <[hidden email]> wrote:

From: Bruce Weaver <[hidden email]>
Subject: Re: Subtracting dates with missing values
To: [hidden email]
Date: Tuesday, September 8, 2009, 2:56 PM

Jill Stoltzfus wrote:
>
>
> Hello everyone. A colleague wants to subtract dates, but she's having
> difficulty doing so because there are some missing values. Any advice
> would be much appreciated.
>
> Thanks.
> Jill
>
>

For any computation, if one of the elements is missing, the result will also
be missing.  So the only way around this, I think, is to impute some date
wherever a date is missing.  Whether it is possible (and reasonable) to do
so is something your colleague will have to judge.



-----
--
Bruce Weaver
bweaver@...
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."

NOTE:  My Hotmail account is for posting only, and is not monitored
regularly.
If you wish to send me an e-mail, please use the address shown in my sig
file.
--
View this message in context: http://www.nabble.com/Data-file-restructure-tp25342662p25352072.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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