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]
st: could someone pls explain me this
From
tashi lama <[email protected]>
To
<[email protected]>
Subject
st: could someone pls explain me this
Date
Mon, 30 Apr 2012 17:24:28 +0000
Hello,
I am doing sth similar to what I found in archive titiled "Re: st: save the value of a string variable into a macro". I am not sure if I followed the code although it looks relatively st. forward.
Here is the dataset and goal
+-----------------------------+
| depcom nomcom |
|-----------------------------|
1. | 18001 Acheres |
2. | 18002 Ainay-le-Vieil |
3. | 18003 Les Aix-d'Angillon |
4. | 18004 Allogny |
5. | 18005 Allouis |
+-----------------------------+
Where depcom is an id. I want to save a specific values of the variable "nomcom" into a variable, for example, I want to obtain :
. di "`mymacro'"
Archeres
The code is
tempvar tv1
gene `tv1'=_n if depcom==18003
summ `tv1', meanonly
local index=r(min)
local mymacro=nomcom[`index']
drop `tv1'
I follow line 1 and 2. I am not sure why we need line 3. Line 4 established a macro which is used in line 5. But, I don't follow why the macro takes r(min) as expression. I would think the macro `index' should capture the value(the only value in fact) in tv1.
Thanks,
Tashi
*
* 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/