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

From |
"Michael I. Lichter" <mlichter@buffalo.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: forvalues and _N |

Date |
Fri, 10 Oct 2008 15:02:26 -0400 |

"[...] `expansion_optr' [...]"

Michael Nick Cox wrote:

I think what Michael wants to know is documented better at -help macro-. `=exp' where exp is an expression lets you evaluate an expression on thefly and use its result.`=2 + 2' would be in these terms: the expression is 2 + 2; Stata wouldevaluate that; and the command would see 4.As the example implies, the expression can be a single item such as _N.This has been in Stata since (I think) sometime during Stata 7 but wasnot documented until Stata 8. There is a discussion withinSJ-3-2 pr0009 . . . . . . . . . . . . . Speaking Stata: Problems with lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox Q2/03 SJ 3(2):185--202 (no commands) discusses ways of working through lists held in macroswhich is visible under the 3-year rule.Nickn.j.cox@durham.ac.ukP.S. The help and the manuals are, as always, the first documentation to think of. Typically, the FAQs fill in some odd gaps or fill out sometricky topics.Martin Weiss see -help _variables-. The equal sign evaluates this -expression- so noneedfor any -macro-...Michael I. LichterWhoa! This works even though `=_N' is clearly not a macro. Is this anundocumented feature, or is it a "real" part of Stata that will stickaround? I'm sorry if this is discussed somewhere in the FAQ -- I havenoidea how to search for it.Philip Ryan wrote:Try: forvalues i = 1/`=_N' { .... }* * 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/

-- Michael I. Lichter, Ph.D. Research Assistant Professor & NRSA Fellow UB Department of Family Medicine / Primary Care Research Institute UB Clinical Center, 462 Grider Street, Buffalo, NY 14215 Office: CC 125 / Phone: 716-898-4751 / E-Mail: mlichter@buffalo.edu * * 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/

**Follow-Ups**:**RE: st: forvalues and _N***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: forvalues and _N***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**References**:**st: forvalues and _N***From:*"Bastian Steingros" <Steingros@gmx.de>

**Re: st: forvalues and _N***From:*Philip Ryan <philip.ryan@adelaide.edu.au>

**Re: st: forvalues and _N***From:*"Michael I. Lichter" <mlichter@buffalo.edu>

**Re: st: forvalues and _N***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**RE: st: forvalues and _N***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: Basic regression interaction term question** - Next by Date:
**Re: st: loop to rename vars** - Previous by thread:
**RE: st: forvalues and _N** - Next by thread:
**Re: st: forvalues and _N** - Index(es):

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