Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: generating number list depending on another variable


From   Patricia Biedermann <[email protected]>
To   [email protected]
Subject   st: generating number list depending on another variable
Date   Wed, 19 Mar 2014 15:34:56 +0100

Dear all,

Following problem:
I have variable1 with different values (AL, BS, SF, ZK...etc.) and
want to create another variable with a list of numbers reaching from
e.g. 1-100;
For each value in variable1 there should be the same number in
variable2; it should look like that in the end:

Variable 1                                Variable 2
AL                                             1
AL                                             1
AL                                             1
BS                                             2
BS                                             2
BS                                             2
BS                                             2
BS                                             2
SF                                             3
SF                                             3
ZG                                             4
etc                                            etc.

I tried to use egen variable2=fill(1(1)100) also in combination with
foreach; somehow generates values from 1-100 independently from
Variable 1

Thank you!
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index