Statalist The Stata Listserver


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

Re: st: inconsistent behavior of -ds-


From   n j cox <[email protected]>
To   [email protected]
Subject   Re: st: inconsistent behavior of -ds-
Date   Thu, 07 Sep 2006 11:00:19 +0100

Kit Baum and Scott Merryman pointed out that there is
no inconsistency here. -ds- is behaving as advertised.

But the original problem seems soluble more directly.

If you know you want to pick up the names of the third to last
variables, you can just go

ds pres1-vp1

or

unab foo : pres1-vp1

Caleb Southworth

I have been using -ds- to identify r(varlist) and then loop through those variables. However, I am puzzled by the behavior of -ds, has(type #/#)- syntax.

To illustrate what appears to be inconsistent behavior of -ds-, consider
this dataset with 9 string variables:

. desc

Contains data from uniondemoc82-3.dta
obs: 180
vars: 10
size: 40,500 (99.9% of memory free)
-------------------------------------------------------------------------------
storage display value
variable name type format label variable label
-------------------------------------------------------------------------------
union str80 %80s
id int %8.0g
pres1 str20 %20s
treas1 str17 %17s
sect1 str20 %20s
sect2 str16 %16s
st1 str20 %20s
st2 str16 %16s
st3 str11 %11s
vp1 str19 %19s

. ds
union id pres1 treas1 sect1 sect2 st1 st2 st3
vp1

. ds , has(type string)
union pres1 treas1 sect1 sect2 st1 st2 st3 vp1

. ds, has(type 2/8)

. ds , has(type 2/62)
pres1 treas1 sect1 sect2 st1 st2 st3 vp1

. ds , has(type 2/11)
st3

My goal is to have r(varlist) contain all the variables except the first
two (union and id), one of which is a string, other other numeric.

The question here is why -ds- lists some of the variables, specific
variables, or all variables.

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