Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: question about ds command
From
"Nick Cox" <[email protected]>
To
<[email protected]>
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
[email protected]
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/