Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Resdesigning dyadic data formats


From   "Neumayer,E" <[email protected]>
To   <[email protected]>
Subject   st: RE: Resdesigning dyadic data formats
Date   Wed, 21 Apr 2004 11:35:37 +0100

Dear Nick,

thanks. I can see how this creates a nice rectangular dataset. However, how could I get Stata to take the values of the x-variables over? At the moment, the "1-2" pair, for example, has 567 as value for the x-variable, but after fillin, the "2-1" pair, which now exists, is empty for the x-variable, but I'd like to have it as 567 as well. Any help greatly appreciated again.

Best, Eric

------------------------------

Date: Tue, 20 Apr 2004 14:18:13 +0100
From: "Nick Cox" <[email protected]>
Subject: st: RE: Resdesigning dyadic data formats

fillin c1 c2
replace x = . if _fillin
drop _fillin 

Nick 
[email protected] 

Neumayer,E
 
> I have a "dyadic" dataset that looks like this (which is the 
> traditional way of setting up such data):
> 
> c1	c2	x
> 1	2	567
> 1	3	345
> 1	4	7
> 1	5	348
> 2	3	47
> 2	4	3
> 2	5	48
> 3	4	23424
> 3	5	347
> 4	5	234
> 
> The "c1" and "c2" are identifiers for the two dyads. I would 
> like to re-design the data to have it in the following format:
> 
> c1	c2	x
> 1	1	
> 1	2	567
> 1	3	345
> 1	4	7
> 1	5	348
> 2	1	567
> 2	2	
> 2	3	47
> 2	4	3
> 2	5	48
> 3	1	345
> 3	2	47
> 3	3	
> 3	4	23424
> 3	5	347
> 4	1	7
> 4	2	3
> 4	3	23424
> 4	4	
> 4	5	234
> 5	1	348
> 5	2	48
> 5	3	347
> 5	4	234
> 5	5	
> 
> Note that now the identical pairs (1-1, 2-2, 3-3, 4-4, 5-5) 
> have missing x-values, of course, and that all x-values exist 
> twice now (e.g., once for 1-5, and once for 5-1). I know, one 
> could do this redesigning by hand, but given that my actual 
> dataset is far bigger, I am looking for a way to let Stata do 
> the work for me. Any ideas?
> 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index