This is set as an exercise to see if you understood
the lesson. Alternatively, an untested solution
is at the end.
Suggested reading:
How to move step by: step. Stata Journal 2(1):86-102.
(explains the use of the by varlist : construct to tackle
a variety of problems with group structure, ranging from
simple calculations for each of several groups to more
advanced manipulations that use the built-in _n and _N)
Nick
[email protected]
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Neumayer,E
> Sent: 21 April 2004 14:24
> To: [email protected]
> Subject: st: RE: RE: RE: Resdesigning dyadic data formats
>
>
> Nick, great! Now, one more complication. Your advice works if
> there are dyads in just one year. But assume now that there
> is also a year variable. OK, with "fillin c1 c2 year" I get
> the dataset in a nice rectangular shape. What adjustment do I
> need to make for the other four lines:
>
> gen max = max(c1,c2)
> gen min = min(c1,c2)
> bysort max min (x) : assert _N == 2
> by max min: replace x = x[1] if missing(x)
>
gen max = max(c1,c2)
gen min = min(c1,c2)
bysort max min (year x) : assert _N == 2
by max min year: replace x = x[1] if missing(x)
*
* 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/