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, statalist.org 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" <cpoliquin@hbs.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: _byn1() and _byn2() variables in numlist
Date   Mon, 27 Sep 2010 17:39:40 -0400

Hello,

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
2
1
invalid syntax
r(198);

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,
Chris

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index