Statalist


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

Re: st: RE: saving local macros


From   Ulrich Kohler <[email protected]>
To   [email protected]
Subject   Re: st: RE: saving local macros
Date   Fri, 16 Jan 2009 12:09:37 +0100

Greg Combs schrieb:
> Thanks to the 244 character limit in Stata, I'm running into some  
> difficulty while working on very long strings.
> 
> I'm wondering if there's ever been any effort to write some string  
> wrapper functions for notes/characteristics, since they don't have  
> this byte limitation.

...

> Maarten's information about pulling out the note as a local macro  
> seems to be a good first step here ...
> 
> 	`_dta[note1]'
> 
> But I'd love to know if anyone's considered or started a library to  
> have things like index, subinstr, regexr, regexm, word, itrim, substr  
> operations on notes/characteristics or other lengthy data containers.
> 
> Alternatively, if the kind folks at Stata want to give us a bigger  
> character limit for strings in Version 11, I certainly wouldn't  
> complain.

While waiting for version 11 you might want to look at the "extended
macro functions". These functions work with locals and globals and hence
also with chars after using

. local example `_dta[note1]'

Extended macro functions don't have the limitation of the "normal"
string functions. For example instead of

. local example = subinstr("this is a long string","long","short",.)

you might want to  try out

. forv i = 1/100 {
.	local x "`i' this is a long string `x'"
. }

. local example: subinstr local x "long" "very long", all

Other extended functions are:

word count string
word # of string
piece #_1 #_2 of [`]"string"['] [, nobreak ]
length { local | global } macname
subinstr { local | global } macname [`]"from"['] [`]"to"['] [, ll word
count({ local | global } macname) ]

Many regards
Uli

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index