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, 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 <>
To   <>
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:


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:

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