You can put the variable name in a local macro, like this:
. ds
. local var3 : word 3 of `r(varlist)'
. describe `var3'
You'll have to do this for each file.
David
--
David Radwin
Senior Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794
www.mprinc.com
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Pradipto Banerjee
> Sent: Tuesday, November 06, 2012 11:23 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: getting the nth column name
>
> I want to write a code to read the 3rd column from a few different
> datasets. My issue is that the 3rd column can have different names in
> different datasets. Is there any function or command that returns the
name
> of the Nth column ?
>
> For instance, suppose file F1 has the 3rd column as F1xyz and F2 has the
> 3rd column as F2abc, I want a generic way to refer to F1xyz and F2abc
with
> an -ado- program?
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/