Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Help with varlist manipulation


From   "K Jensen" <[email protected]>
To   [email protected]
Subject   Re: st: RE: Help with varlist manipulation
Date   Thu, 23 Nov 2006 12:24:28 +0000

I've found that the following works for my needs (which was just to
produce lists of categorical and non-categorical variables to document
output for other people) by using the variable labels produced by xi:
local xid
local not_xid
foreach v in `vars' {
 local label: var label `v'
 if strpos("`label'","==")>0 {
   local lbl = substr("`label'",1,strpos("`label'","==")-1)
   label var `v' "`lbl'"
   local xid `xid' `v'
 }
 else {
   local not_xid `not_xid' `v'
 }
}

local label2
local xid2
foreach x in `xid' {
 local label2 `label2' `:var label `x''
}
local xid2: list uniq label2

I am aware that it wouldn't work to produce actual variable names for
long names that had been abbreviated or for "non-standard" xi
settings, but it solves my specific problem for the dataset I am
working on.

Karin

On 20/11/06, Nick Cox <[email protected]> wrote:
Sorry, I am left more confused than before.

Either way, I can't see an easy way of working back from
what is left in memory after -xi:- to what was fed to it.
This includes looking at -s()- results.

Nick
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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