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: RE: getting the nth column name


From   "David Radwin" <dradwin@mprinc.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: getting the nth column name
Date   Tue, 6 Nov 2012 11:37:14 -0800 (PST)

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/


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