[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Fwd: Re: st: from value to varnames]

From   "Nick Cox" <>
To   <>
Subject   RE: [Fwd: Re: st: from value to varnames]
Date   Tue, 19 May 2009 14:12:46 +0100

As Phil Schumm half-stated earlier, I am the author of -sxpose-, which
is on SSC. (There are other Nicks, old and young.) 

There is only version of -sxpose-, 1.0.0. 

The help warns 

-firstnames- specifies that the first variable (first column) in the
existing dataset is to be treated as a set of variable names for the
variables in the transposed dataset. This first column will not appear
as the first observation in the new dataset. Any values that are not
legal variable names will be lost.

Ideally, Rich can just get rid of his hyphens by 

replace field = subinstr(field, "-", "", .) 

Another thing to look out for that the values of -field- are all
distinct. There are several ways to check that. There is a survey in 

SJ-8-4  dm0042  . . . . . . . . . . . .  Speaking Stata: Distinct
        (help distinct if installed)  . . . . . .  N. J. Cox and G. M.
        Q4/08   SJ 8(4):557--568
        shows how to answer questions about distinct observations
        from first principles; provides a convenience command


Richard Goldstein

data error -- it turns out that some of the strings in "field" contained

hypthens -- since varnames cannot contain hyphens, sxpose would not do 
the rename -- but gave me no error message -- sorry for the confusion

From: Richard Goldstein <>

not on my machine -- I even downloaded a new copy of sxpose (from ssc)
and did exactly what you suggested (via cut-and-paste) and the new
varnames are _var# (258 of them)

so ...

Phil Schumm wrote:
> On May 18, 2009, at 8:19 PM, Richard Goldstein wrote:
>> nope -- Nick's -sxpose- gives me variables with varnames _var1, etc
>> which is of no use; sorry for not mentioning that I had already tried
> That's what the -firstnames- option does.  Without it, you'll get 
> variables named _var1, _var2, etc.  With -firstnames-, you'll get 
> variables named namea, nameb, etc.

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index