Statalist


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

st: Re: manage list of variables


From   Maarten buis <[email protected]>
To   stata list <[email protected]>
Subject   st: Re: manage list of variables
Date   Thu, 12 Nov 2009 21:30:23 +0000 (GMT)

--- joachim jarreau wrote:
> Id like to know if there exists a way to create
> a local list of the existing variables in a dataset,
> In other words id need to do something like :
> collapse (sum) value, by( "all variables except this-that").


you can get a list of variables using the -ds- command, see: 
-help ds- and Martin Weiss (2008) Stata tip 66: ds—A hidden 
gem. The Stata Journal, 8(3):448-448. 
http://www.stata-journal.com/article.html?article=dm0040 .

You can remove a set of variables from that list using extended 
macro functions, see -help macrolists- and the example below:

*-------- begin example -------------
local except "make"
sysuse auto, clear
ds 
local varlist `r(varlist)'
local newlist: list varlist - except
di "`newlist'"
*----------- end example ------------

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

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