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

From |
"Martin Weiss" <martin.weiss@uni-tuebingen.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: RE: Trouble with `=`_N'-1' |

Date |
Mon, 1 Sep 2008 18:02:57 +0200 |

On that point: while writing my post, I dodged the question of how to call _N by its name. I probably should have said "system variable", as in -h _variables-... Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: Monday, September 01, 2008 5:51 PM To: statalist@hsphsun2.harvard.edu Subject: st: RE: RE: Trouble with `=`_N'-1' Just to underline Martin's analysis: the reference `_N' would be appropriate if _N were the name of a local macro, but _N is not a local macro. Nick n.j.cox@durham.ac.uk Martin Weiss Stata does not know what to do about `_N', so it evaluates to nothing. The whole -in- statement evaluates to - in -1 - which denotes the last observation. Say -replace line = 5 in `=_N-1'- and it works fine. Now _N is well defined and the expression evaluates to the desired value. Note that you could have put - in -2 - to begin with, and would have saved yourself the trouble... Ashim Kapoor I wish to make a change in the 2nd last observation. so I have : replace line = 5 in `=`_N'-1' But this change the LAST observation! Am I doing something wrong? funnily replace line = 5 if _n==_N-1 works fine! * * 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/ * * 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/

**References**:**st: Trouble with `=`_N'-1'***From:*"Ashim Kapoor" <ashimkapoor@gmail.com>

**st: RE: Trouble with `=`_N'-1'***From:*"Martin Weiss" <martin.weiss@uni-tuebingen.de>

**st: RE: RE: Trouble with `=`_N'-1'***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: RE: RE: Trouble with `=`_N'-1'** - Next by Date:
**st: acces data in jackknife command.** - Previous by thread:
**st: RE: RE: Trouble with `=`_N'-1'** - Next by thread:
**Re: st: RE: Trouble with `=`_N'-1'** - Index(es):

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