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

From   "David Radwin" <>
To   <>
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 Radwin
Senior Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794

> -----Original Message-----
> From: [mailto:owner-
>] On Behalf Of Pradipto Banerjee
> Sent: Tuesday, November 06, 2012 11:23 AM
> To:
> 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
> 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
> an -ado- program?

*   For searches and help try:

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