Statalist The Stata Listserver


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

RE: st: RE: Help with varlist manipulation


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Help with varlist manipulation
Date   Thu, 23 Nov 2006 12:43:16 -0000

Glad you solved your problem.
Looking at variable labels is a good idea that didn't 
occur to me. 

As you imply, this would need more work 
to cover variables that are interaction terms, which 
I would regard as a standard application of -xi-. 

Nick 
[email protected] 

K Jensen
 
> 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.

*
*   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