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


From   "David Radwin" <[email protected]>
To   <[email protected]>
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: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Pradipto Banerjee
> Sent: Tuesday, November 06, 2012 11:23 AM
> To: [email protected]
> 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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index