Thanks for the alternate solutions. I implemented the "foreach v of
varlist" method and that works fine. Pat G.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: Tuesday, July 11, 2006 2:34 PM
To: [email protected]
Subject: st: RE: How to prevent truncated string in macro expression
You're correct.
local temp4 : subinstr local varlist " " ",", all
Start with
. help macro
and then click on "extended_fcn".
However, I wouldn't do what you want to do that way.
If you are bitten by what you feed to -subinstr()-,
you will be bitten sooner or later by what you feed
to -missing()-.
What you want can be done by calling -egen, rowmiss()-
or -- a little more efficiently -- by
something like
tempvar ismiss
gen byte `ismiss' = 0
qui foreach v of local varlist {
replace `ismiss' = max(`ismiss', missing(`v') & `touse')
}
qui count if `ismiss'
Nick
[email protected]
Grealy, Patrick J
> I am having trouble with the limit for string lengths in
> expressions and
> have not been able to find the solution. I'm sure I've seen
> it somewhere
> and suspect it involves using the colon(:) instead of
> equals(=) method.
> Here's the relevant section of code from my .ado file for a program
> that, among other things, attempts to count the number of missings for
> any of the input variables:
>
> local temp4=subinstr("`varlist'"," ",",",.)
> quietly count if missing(`temp4') & `touse'
>
> I replace spaces in varlist with commas and save in a local macro and
> use it as the argument for the missing function. This works
> fine until I
> use too many variables and exceed the string limit. Can
> someone help me
> with a method to get the macro to include the entire string?
*
* 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/
*
* 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/