Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "William Gould, StataCorp LP" <wgould@stata.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: References for `= foo' |
Date | Wed, 31 Jul 2013 12:32:51 -0500 |
Sergiy Radyakin <serjradyakin@gmail.com> wrote, > > If there is a function or a reference to a variable in the dataset > > that you want to get evaluated, you place '=' in front. Be careful > > with strings as string expressions are subject to a rather low chars > > limit (not sure about Stata 13). Wayne Folta <wfolta@mac.com> replied, > It appears that it's longer than in the past. In Stat/IC 13 I just > created a local macro using = and not using = that was 1700 characters > long in both cases. If I did this correctly, this is a huge > improvement! Yes it is. How many times has someone written to Statalist about their program being broken because they coded, local cp = "`varlist'" Well, that's not a problem anymore. Stata's expression parser is now up to working with 2-billion character strings. In fact, you'll want to start thinking of macros as being short. The maximum length of a macro is a mere 1,081,511 characters. This lead Sergiy to write, > Before 13 we could be sure that any value of a string variable could > be fit into a macro, but not every macro (potentially 1 mln chars) > could be saved into a value of a string variable (up to 244 chars). > Now in 13 we have the reverse problem: [...] I have a solution. To handle the problem of string variables not fitting into macros, we updated string scalars in Stata 13. String scalars can now hold strings up to 2-billion characters long, and they can be binary to boot. In programs, you code program ... version 13 ... tempname mystr ... ... scalar `mystr' = ... ... generate ... = ... `mystr' ... ... end That is, use string scalars to store the values of variables, name the scalars using the -tempname- function, and then use the temporary name in other Stata commands just as you would have the macro, except do not double-quote the name. -- Bill wgould@tata.com * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/