Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: could someone pls explain me this


From   tashi lama <ltashi32@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index