Statalist The Stata Listserver


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

st: RE: RE: RE: RE: RE: SImple question on "describe"


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: RE: RE: SImple question on "describe"
Date   Wed, 21 Jun 2006 09:46:36 +0100

No, not quite. David needs the labels stored to put them 
back again. That's half the point of his program. Thus
the scope for simplification is much less, but there's 
still a bit. 

prog tablevl
	version 8
	syntax varlist(min=1 max=3) [if] [in] [fw aw pw iw] [, *]

	local i 0
	foreach v of local varlist { 
		local lab`++i' : var lab `v'
		label var `v' `"`v': `lab`i''"'
	}
	cap nois table `varlist' `if' `in' [`weight' `exp'], `options'
	local rc _rc
	 
	local i 0
	foreach v of local varlist { 
		label var `v' `"`lab`++i''"'
	}

      if `rc' exit `rc'
end

Nick 
[email protected] 

Nick Cox
 
> tokenize `varlist'
> local i 0
> while !missing("``++i''") {
> 	local lab`i' : var lab ``i''
>       label var ``i'' `"``i'': `lab`i''"'
> }
> 
> can be boiled down to 
>  
> foreach v of local varlist { 
> 	label var `v' `"`v': `: var label `v''"'
> }

David Harrison
 
> > > Sorry, some of my code got a little mixed up there... 
> > > Corrected version
> > > below... 
> > > 
> > > prog tablevl
> > >     version 8
> > >     syntax varlist(min=1 max=3) [if] [in] [fw aw pw iw] [, *]
> > >     tokenize `varlist'
> > >     local i 0
> > >     while !missing("``++i''") {
> > >         local lab`i' : var lab ``i''
> > >         label var ``i'' `"``i'': `lab`i''"'
> > >     }
> > >     cap nois table `varlist' `if' `in' [`weight' `exp'], `options'
> > >     local rc _rc
> > >     local i 0
> > >     while !missing("``++i''") {
> > >         label var ``i'' `"`lab`i''"'
> > >     }
> > >     if `rc' {
> > >         exit `rc'
> > >     }
> > > end

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