Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: _byn1() and _byn2() variables in numlist

From   "Poliquin, Christopher" <>
To   "" <>
Subject   st: _byn1() and _byn2() variables in numlist
Date   Mon, 27 Sep 2010 17:39:40 -0400


I am attempting to use the _by variables in a byable program, but am running into problems with syntax problems and invalid numlists that I cannot figure out how to resolve:

I do...

. program testing, byable(recall)
  1.         marksample touse
  2.         di _byn2()
  3.         di _byn1()
  4.         forvalues x = _byn2()(-1)_byn1() {
  5.                 di `x'
  6.         }
  7. end
. bys foo : testing

And get ...
-> foo = 1
invalid syntax

And when using a numlist, i.e. foreach x of numlist _byn2()(-1)_byn1(), I get an invalid numlist error.

How do I cycle through each observation number in a group within a byable program?

Best wishes,

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index