Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: RE: question about ds command


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: question about ds command
Date   Wed, 12 May 2010 20:48:11 +0100

This is nothing to do with -ds-. 

It is the problem discussed yesterday in 

<http://www.hsph.harvard.edu/cgi-bin/lwgate/STATALIST/archives/statalist
.1005/date/article-524.html> 

Namely, the = sign in your assignment truncates the macro as a
side-effect. See the above posting for references discussing the problem
in nauseating detail. 

For your problem, there is a very direct alternative. 

unab a : *_test 

(Note that unlike -levelsof-, -ds- does not have a -local()- option. But
-findname- from SSC, which is a user-written revision of -ds-, does. But
for this question, -unab- is far more direct than -findname-, or indeed
-ds-.) 

Nick 
n.j.cox@durham.ac.uk 

Dr. Bill Westman

I have a question on the function of ds related to the following:

forvalues x = 1/50 {
g q_`x'_test = 1
}
ds *_test
** displays the list of q_1_test - q_50_test perfectly **
local a = r(varlist)
disp "`a'"
** DOES NOT Contain all variables.  list is truncated after q_25_test q_
**

I'd like to accomplish putting a long list of variables with using "*_"
into a local macro (e.g., everything with that has the suffix _test).


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index