Statalist


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

st: set obs equal to a scalar


From   Jacob Wegelin <jwegelin@vcu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: set obs equal to a scalar
Date   Tue, 16 Sep 2008 14:06:26 -0400 (EDT)

In the example below, it is impossible to set obs equal to a scalar value 5, but it is possible to set obs to equal the same value 5 when it is stored in a local macro. Why? Is there no way to set obs equal to a scalar?

. clear

. scalar define ObsPerPerson=5

. di ObsPerPerson
5

. set obs ObsPerPerson
'ObsPerPerson' found where integer expected
r(198);

. set obs `ObsPerPerson'
invalid syntax
r(198);

. set obs "`ObsPerPerson'"
'"' found where integer expected
r(198);

. local heyThere 5

. set obs `heyThere'
obs was 0, now 5


Jacob A. Wegelin
jwegelin@vcu.edu Assistant Professor
Department of Biostatistics
Virginia Commonwealth University
730 East Broad Street Room 3006
P. O. Box 980032
Richmond VA 23298-0032
U.S.A. http://www.people.vcu.edu/~jwegelin
*
* 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   |   What's new   |   Site index