Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Unexpected -egen , fill()- behavior


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: Unexpected -egen , fill()- behavior
Date   Sat, 02 Dec 2006 11:18:09 -0500

Joseph Coveney wrote:
> There's undoubtedly something obvious why the numlist below doesn't give me
> five groups of four each.  Can anyone point out where I'm going wrong?
>

I'd say not obvious, and also point out that -x- and -y- are
irrelevant:

. clear

. set obs 20
obs was 0, now 20

. egen group=fill(1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5)

. list, noobs sepby(group)

  +-------+
  | group |
  |-------|
  |     1 |
  |     1 |
  |     1 |
  |     1 |
  |-------|
  |     2 |
  |     2 |
  |     2 |
  |     2 |
  |-------|
  |     3 |
  |     3 |
  |     3 |
  |     3 |
  |     3 |
  |     3 |
  |-------|
  |     4 |
  |     4 |
  |     4 |
  |     4 |
  |-------|
  |     5 |
  |     5 |
  +-------+

.

Looks like a bug. However, -fill- really just needs to get the
pattern started, so you'll find that:

. egen group=fill(1 1 1 1 2 2 2 2 )

will do what you need.

hth,
Jeph



Joseph Coveney

. set seed `=date("2006-12-03", "ymd")'

. drawnorm y x, corr(1 0.5 \ 0.5 1) n(20) clear
(obs 20)

. sort x

. egen byte group = fill(1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5)

. list, noobs sepby(group)

 +-------------------------------+
 |         y           x   group |
 |-------------------------------|
 |  -1.04372   -2.458569       1 |
 | -.6301845    -1.53749       1 |
 | -.4474874   -1.227146       1 |
 |  -.538601   -1.158167       1 |
 |-------------------------------|
 |  .0999929   -1.140627       2 |
 | -.7626165   -1.040885       2 |
 | -.8379411   -.9000927       2 |
 | -1.199746   -.8086246       2 |
 |-------------------------------|
 | -.2398437   -.6472539       3 |
 |  .4926107   -.6277131       3 |
 |  .3099134   -.5799699       3 |
 |  .7792414   -.4452717       3 |
 |  .5397932   -.1693323       3 |
 |  .6346364   -.1348845       3 |
 |-------------------------------|
 | -.3965632   -.0002388       4 |
 | -.3926637    .1616845       4 |
 | -.3358584    .2037638       4 |
 | -.5474986    .5839815       4 |
 |-------------------------------|
 |  .1766358     .701948       5 |
 |   .085008    .8024728       5 |
 +-------------------------------+

.

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


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