| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: long macro
The issue is not whether it is a string. It is
that you are evaluating when you should be copying.
The limit that bites is different.
Given Stata 9, -while- is less direct than -forval-.
local codelist
forval i = 1/`= _N' {
local codelist `codelist' `=icd10code[`i']'
}
That said, what you want is already provided by either
-levelsof- in official Stata or the -valuesof- just
announced by Ben Jann.
Nick
[email protected]
Seb Buechte
It looks to me like you are entering a "string" into the local macro
and strings in Stata are limited to 244 characters. You may to try
this:
local i=1
local codelist
while `i'<= _N {
local codelist `codelist' `=icd10code[`i']'
local ++i
}
Dedman, Dan
> I was trying to create a macro that contained a long list of (icd10)
codes that are stored in a temporary dataset. There are 290 obs and
icdcode is str4 variable, so I reasoned that thereshould not be any
problem storing this many characters in a macro. Intercooled stata has a
limit of around 68000 characters in a macro, so I was surprised to find
that the that the code works fine until "`codelist'" reaches 244
characters in length. After that it fails to grow in subsequent iterations.
>
> My code looks like this:
> <snip>
> version 9
> local i=1
> local codelist
> while `i'<= _N {
> local codelist = "`codelist'" + " " + icd10code[`i']
> local ++i
> }
> <snip>
>
*
* 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/