Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: "sort" over different variables - thanks Nick and Martin


From   Niels Schenk <[email protected]>
To   <[email protected]>
Subject   Re: st: "sort" over different variables - thanks Nick and Martin
Date   Tue, 25 Aug 2009 13:21:52 +0200

This should do the trick:

reshape long M Birth_dateM, i(ID) j(suf)
bys ID (M): replace suf = _n 
reshape wide M Birth_dateM, i(ID) j(suf)

cheers,

Niels


On Tue, 25 Aug 2009 12:28:07 +0200, "[email protected]"
<[email protected]> wrote:
> Thanks Nick and Martin for your answers and help. 
> 
> Rowsort is a great tool and could be one solution (by the way it will
help
> me with other problems not mentioned here). However, I will describe my
> (original) problem in greater detail and describe why rowsort may not be
> the best solution (sorry for the earlier (and poor) description of my
> problem):
>  
> My dataset contains detailed information on organizational members (e.g.
> their date of entry). However, the dataset is not well structured, i.e.
in
> some cases there is a member1 and a member3 while a member 2 is missing.
In
> these cases, member3 is obviously member2. At this point, rowsort would
> help me fixing the problem. Using rowsort member1 would be the member
that
> entered the organization at first, member2 would be the member that
entered
> the organization at second, and so on.
>  
> However, my dataset includes additional information about the members,
as
> for example, their birth date. If I use rowsort to “rank” the members of
> the organizations, birth dates do not fit any longer. Additionally, I
could
> not use rowsort to rank the birth dates, since the member that entered
> first may not be the youngest.
>  
> My dataset looks like this (still simplified…). M1, M2 and M3 are the
> times of entry of the members.
>  
> ID   M1   M2   M3   Birth_dateM1   Birth_dateM2   Birth_dateM3
> 1     100   50    200          1970                 1980                

> 1960                  
> 2      ...
> 3     …
>  
> And should look like this:
>  
> ID   M1   M2   M3   Birth_dateM1   Birth_dateM2   Birth_dateM3
> 1      50   100   200          1980                 1970                

> 1960                  
> 2      ...
> 3     …
>  
>  
> Do you have any idea how to fix this problem (is there a solution within
> rowsort)?   
> Thanks again for any reply and help.
> Simon
> 
> 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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