Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: AW: st: local containing (all) variables' names in a dataset


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: AW: st: local containing (all) variables' names in a dataset
Date   Tue, 18 Aug 2009 17:49:22 +0100

That's a fair assumption about command names. In this case, names other
than -ds- did originally indicate later and supposedly better versions,
but no longer. 

But the full story is complicated. This is all really for StataCorp to
comment or explain, but I'll give my take on the story. 

I think it needs a little history, or at least one version of what is
remembered as the history. 

1. -describe- featured in Stata 1.0. -ds- followed as a way of getting
concise display of variable names only. (As typical datasets got bigger,
the need for a concise alternative to -describe- became more common.) 

2. At various times I hacked at -ds- to extend it, under various names
starting with -ds-, and later the best extensions got taken back into
the official -ds-. That was during the lifetime of Stata 8. (For
completeness, I'll emphasise that I have not touched -ds- since.) There
was more emphasis in -ds- on leaving names behind in usable form, e.g.
as r(varlist). From one point of view, these changes subverted the
purpose of -ds-. It morphed from a command with a display function to
one that was primarily for getting varlists for later use. Although it
has yet to materialise, a name -varfind- was floating around at one
stage as a name to explain better what it does. 

3. However, -describe- did not stay unchanged. For example -describe,
simple- was introduced as a way of getting what -ds- used to do.
-describe- has changed so that more stuff may be retrieved for future
use. (Many users internalised -describe- in their first week with Stata,
have not looked at the help in years, and may now be several versions
out-of-date on what it can do.) 

4. In terms of getting varlists, the basic tools rapidly became those
documented at [P] macro. However, -ds- does let you do in a line some
things that might take a little while to figure out. I don't think -ds-
is superseded as a whole. I think the statement you quote is incorrect
about -ds-. 

5. There are those in high places _who dislike the syntax of -ds-_.
Discretion is the better part of revelation, but you know you are, even
if your arguments have failed to conVince me, or I have yet to see a
better syntax. 

6. As various people have emphasised, -ds- is still there and still
matched by help, just not documented in the manual. Everyone must have
noticed that the manuals are under strain, and if there is a command
that most users can do without it is a candidate for deletion. It's a
real compliment to Stata that there is very little that is completely
useless, so that each deletion tends to be painful to a few enthusiasts.


7. -ds- remains an official command. There is absolutely nothing
unofficial about it. 

Nick 
[email protected] 

Eric A. Booth

Thanks for the clarification, Nick.  I made the erroneous assumption  
that an increase in the number after -ds- (e.g., ds2, ds3, ds5...)  
meant newer versions of the program.

   Since -ds- is now an undocumented/unofficial command,  I am curious  
whether there are other commands that have its functionality.  In the  
"previously documented" link in the -ds- help file it says:

" Previously documented commands are commands of Stata from a previous  
release that are no longer documented because they have been  
superseded by more recent, better commands. "

I see that you can grab a c(varlist) from commands like -desc- and you  
could probably use extended macro functions to piece together what - 
ds- does, but is there another command that has -ds- 's functionality  
built in & supersedes -ds- ??

On Aug 17, 2009, at 3:15 PM, Nick Cox wrote:

> Thanks to Eric and to other friends of -ds- for various plugs.
>
> There is some risk here of various small confusions. Let me clarify.
>
> 1. The official version of -ds- is the latest version there is. It
> incorporates all my contributions that have lasting value, in my view
> that is.
>
> 2. Otherwise this is the story:
>
> ds5 on SSC is for Stata 5.
>
> ds2 on SSC and in STB-56 is for Stata 6.
>
> ds2 in STB-60 is for Stata 7.
>
> ds3 on SSC is for Stata 7.
>
> So, unless you are using an ancient Stata, the previous versions are  
> of
> no current interest. They aren't even of historic interest! The key
> point is that both the STB and SSC are archives, and thus inevitably
> contain some superseded and obsolete stuff.
>
> Nick
> [email protected]
>
> Eric A. Booth
>
> It's been updated to newer versions  by Nick Cox--see  -ds3- and -ds5-
>
> ssc install ds3
> ssc install ds5
>
> On Aug 17, 2009, at 1:06 PM, David Jacobs wrote:
>
>> But -ds- still can be found after -help-
>
> Martin Weiss
>
>>> " a real hidden gem"
>>>
>>>
>>>
>>> Now demoted to "previously documented" status in Stata 11, though.
>>> Grrr....
>
> Augusto Cadenas
>
>>> thank you very much for these quick answers. -ds- seems to
>>> do a very fine job, a real hidden gem, as Martin wrote. (and yes,  
>>> I'm
>>> aware that I'm replacing the original dataset.)
>
>>> On Mon, Aug 17, 2009 at 3:49 PM, Martin Weiss<[email protected]>
>>> wrote:
>
>>>> On -ds- also see
> http://www.stata-journal.com/article.html?article=dm0040
>
> Scott Merryman
>
>>>> You can use macro list.  See -help macrolists-
>>>>
>>>> For example:
>>>>
>>>> . sysuse auto ,clear
>>>> (1978 Automobile Data)
>>>>
>>>> . ds
>>>> make          mpg           headroom      weight        turn
>>>> gear_ratio
>>>> price         rep78         trunk         length
>>> displacement
>>>> foreign
>>>>
>>>> . local a = r(varlist)
>>>>
>>>> . local b  make rep78
>>>>
>>>> . local c:list  a - b
>>>>
>>>> . disp "`c'"
>>>> price mpg headroom trunk weight length turn displacement
>>> gear_ratio foreign
>
> On Mon, Aug 17, 2009 at 8:38 AM, Augusto Cadenas
>
>>>>> I have to collapse a series of datasets and I would appreciate
>>> your
>>>>> help. The issue is that these datasets have different variables,
>>> but
>>>>> always the same variable by which I want to collapse. So I have
>>> to run
>>>>> the following command:
>>>>>
>>>>> collapse (mean) id (sum) [all other variables here], by(name)
>>>>>
>>>>> And I would like to embed this in a foreach loop of the type
>>>>>
>>>>> local datasets `"dataset1 dataset2 dataset3"'
>>>>> foreach X of local datasets {
>>>>>    use `X', clear
>>>>>    collapse (mean) id (sum) [all other variables here], by(name)
>>>>>    save, replace
>>>>> }
>>>>>
>>>>> The issue for me is how to create a local that contains the
>>> names of
>>>>> all variables in each dataset, except for "name" and "id". Any
>>>>> suggestions are appreciated!

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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