Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

AW: st: Addressing variables


From   "Christopher Garlich" <[email protected]>
To   <[email protected]>
Subject   AW: st: Addressing variables
Date   Wed, 14 Sep 2011 17:12:50 +0200

Hi Maarten,

yes, this is kind of what I want. But "i" in my case is a variable, and for
each row I want "i" to take on the value that it has in that specific row.
I hope that clarifies my question a bit more.

Thanks a lot and regards
chris  



On Wed, Sep 14, 2011 at 4:08 PM, Christopher Garlich wrote:
> I have tried that already and it just returns: "ambiguous abbreviation". I
> also tried it with a macro, namely:
> Local i i
> And when I then try "avg = rowmean(Lag1 - Lag`i')", STATA actually
> interprets it as lag"i", but not with value of variable i.
> So my problem persists, I'm not able to address the value of i.

Sounds to me like you haven't assigned values to the local macro i.
When Stata evaluates a statement like -Lag`i'- it replace `i' with its
contents. If no contents was specified it adds nothing and -Lag`i'-
evaluates to -Lag-, which in your case is an ambiguous abbreviation.
Assigning it the contents "i", which is what you did when typing
-local i i-, lead to -Lag`i'- to be evaluated as -Lagi-, which
apparently does not exist in your data. What you seem to want is:

local i = 5
egen avg = rowmean(Lag1 - Lag`i')

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index