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

Re: st: Recoding strategy


From   [email protected] (William Gould)
To   [email protected]
Subject   Re: st: Recoding strategy
Date   Wed, 03 Jul 2002 16:39:40 -0500

Nick Winter <[email protected]> wrote, 

> I've got six variables, wherein respondents ranked the importance of each of
> six strategies.  For the vast majority of cases, respondents assigned one
> rank of "1", one of "2" and so on.
>
> Some respondents, however, ranked more than one strategy with the same rank.
> This takes many forms: [...]
>
> We want to do the following [...]  For multiple identical rankings, randomly
> order them, and then rank subsequent ranks sequentially from there.  So, for
> example, if the data look like this for two cases:
>
>      S1 S2 S3 S4 S5 S6
>       1  1  2  3  4  5
>       3  1  1  4  5  6
>
> I would want to change it to:
>
>      S1 S2 S3 S4 S5 S6
>       1  2  3  4  5  6
>       3  1  2  4  5  6
 
I suggest

        . reshape long S, i(id)
        . gen u = uniform()
        . sort id S u
        . by id: replace S = _n
        . reshape wide S, i(id)

where id is a variable that uniquely identifies each of the observations.

-- Bill
[email protected]
*
*   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