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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: Use of results in variable name


From   alec minnema <alecminnema@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index