Statalist


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

st: RE: RE: Creating id number by subgroup


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Creating id number by subgroup
Date   Tue, 6 Jan 2009 19:35:57 -0000

Not so. "2 C" will not be assigned the same value as "1 A". 

Nick 
[email protected] 

Luciana M. Alencar, M.D.

I believe the following will do the job:

egen var1 = group (id title) 

Mike Kim

I would like to create 'var1' in the following table based on id and
title.
I tried "bysort id title: gen var2=_n" and this creates var2 which is 
different from var1.
I also tried "by id: egen var1=group(title)", but egen does not allow
'by'.
How can I create var1?

id  title  var1  var2
1    A      1    1
1    A      1    2
1    B      2    1
1    B      2    2
1    B      2    3
2    C      1    1
2    C      1    2
2    C      1    3
2    D      2    1
2    D      2    2
3    E      1    1
.......

*
*   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