Statalist The Stata Listserver


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

st: -dlist- revised on SSC


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: -dlist- revised on SSC
Date   Wed, 15 Feb 2006 22:48:23 -0000

Thanks to Kit Baum, the -dlist- program in 
a package of the same name on SSC that was 
released last week has been revised. 

To install, type 

ssc inst dlist

or to overwrite an existing program. 

A reminder of the main features follows my signature. 

Martyn Sherriff kindly sent an example in which -dlist- 
fell over when confronted with a variable with 
name _d. This would happen with instructions 
like 

di _d[1] 

or 

local show : di <format> _d[1] 

The reason is that _d is an acceptable 
abbreviation of _dup() as far as -display- 
is concerned, but also that the square brackets
which follow are illegal in a context in which only 
parenthesised expressions are expected. 

In other words, Stata sees this as 

_d    ... so far, so good
[1]   ... not what I expected here 

Similar problems can arise with other variables 
whose numbers begin with underscores. Thus 
suppose you have 

gen _c = 42 
di _c[1] 

_c is an acceptable abbreviation for _continue, 
which is precisely what Stata does. The next 
token Stata sees is 

[1] 

and Stata will display 

1 

(and not 42!). Why it ignores the brackets 
is a story for someone else at another time. 

This conflict thus requires that -display- 
never be shown the name of the variable, 
which is ensured by evaluating it beforehand. 

Thanks to Kevin Crow and Alan Riley for helpful
discussions of this detail. 

There is also a new -trim- option. Note that
this works the other way round from -list-'s. 

Nick 
[email protected] 

> Thanks to Kit Baum, a -dlist- package containing 
> a command of that name has been added to SSC. 
> 
> Stata 8.2 is required. 
> 
> -dlist- arose from a question asked privately by 
> Miguel Ampudia Fraile. 
> 
> -dlist- is a listing command. The -d- element 
> is meant to evoke -describe-. The motivation 
> for -dlist- is that on occasion you may wish
> to look simultaneously at variable names, 
> variable values and variable labels. For example, 
> variable names may be cryptic to some degree, 
> especially if the dataset is new or unfamiliar to 
> you or large or complicated. Ideally, a cryptic 
> variable name will be made clear by a variable 
> label. 
> 
> 
> This is what -dlist- does: 
> 
> . dlist in 1
> 
> 1.
> make           Make and Model            AMC Concord       
> price          Price                     4,099
> mpg            Mileage (mpg)             22
> rep78          Repair Record 1978        3
> headroom       Headroom (in.)            2.5
> trunk          Trunk space (cu. ft.)     11
> weight         Weight (lbs.)             2,930
> length         Length (in.)              186
> turn           Turn Circle (ft.)         40
> displacement   Displacement (cu. in.)    121
> gear_ratio     Gear Ratio                3.58
> foreign        Car type                  Domestic
> 
> That might be useful for looking at just a few observations. 
> 
> By default, you get variable names, labels and values. 
> There are a few options for tweaking output. Perhaps 
> the most useful is scope for abbreviating names and 
> variable labels and even suppressing them: 
> 
> . dlist in 1, name(0)
> 
> 1.
> Make and Model            AMC Concord       
> Price                     4,099
> Mileage (mpg)             22
> Repair Record 1978        3
> Headroom (in.)            2.5
> Trunk space (cu. ft.)     11
> Weight (lbs.)             2,930
> Length (in.)              186
> Turn Circle (ft.)         40
> Displacement (cu. in.)    121
> Gear Ratio                3.58
> Car type                  Domestic

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