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]

st: Use of results in variable name


From   alec minnema <[email protected]>
To   <[email protected]>
Subject   st: Use of results in variable name
Date   Thu, 26 May 2011 11:10:33 +0000

Dear Stata Users,

I have to use many datasets of different sizes and I will use a foreach loop to open them. 
Inside each dataset I look up the last variable in the dataset with 
describe and than I want to know the mean of that variable. So the body of the foreach loop has to look like this:



describe

scalar LastVariable = r(k)

mean(v`destring(LastVariable)')?? (all variables start with a v and then the number of the variable.)


How can I tell stata to look up the variable vX where X is the number saved in LastVariable.

Thank you in advance,



Alec Minnema
University of Groningen 		 	   		  
 		 	   		  
*
*   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