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]

From |
tashi lama <[email protected]> |

To |
<[email protected]> |

Subject |
RE: st: RE: work with larger string length |

Date |
Tue, 27 Mar 2012 19:39:03 +0000 |

Thank you Nick. > From: [email protected] > To: [email protected] > Date: Tue, 27 Mar 2012 17:14:23 +0100 > Subject: st: RE: work with larger string length > > First taking your questions one by one: > > 1. since string limit is 244, what is it about extended function subinstr that makes string limitation non issue. Does extended function increase the acceptable string length which I think is unlikely? > > I don't know what kind of answer you expect here, but the short answer is yes. It is a fact that using -subinstr()- rather than -: subinstr- bites as the limit on the length of strings in string expressions is 244 in all current flavours of Stata. See -help on limits-. I can't expand on why Stata is written this way; that's an interesting question to me too. > > 2. looks like the same question to me. > > 3. when I use length command to find the length of the string in stata12, I get unrecognized command. Any idea. > > Works for me. I can't say what you did wrong, as you don't show any example code. > > . di length("frog") > 4 > > Now I want to comment on your code > > foreach x of varlist hits* { > gen temp=`x' > replace `x'=. > egen tot_`x'=rowtotal(hits*) > replace `x'=temp > drop temp > } > > A better solution (in my view) is implied by advice given earlier in the thread you started previously. > > unab hitlist : hits* > foreach x of local hitlist { > local thislist : list hitlist - x > egen tot_`x' = rowtotal(`thislist') > } > > > Nick > [email protected] > > tashi lama > > I posted a question related to this earlier and received favorable answers although I am not sure if I completely understand the science. I have dared to post this question again. Any help will be highly appreciated. > > I have a dataset of some 48 variables and the nature of my problem obliges me to have all variables start with hit. when I ran this code, > > foreach x of varlist hit* { > local varlist_new=subinstr("`varlist'", "`x'","",1) > di "`varlist_new'" > egen tot_`x'=rowtotal(`varlist_new') > } > > The problem was I did get answers but the upon close analysis, the answers were incorrect. I am assuming it must be because the length of my string variables exceed 244. Now, I was advised to use extended subinstr function, which seem to work. Further I wrote a code below, which also works. > > foreach x of varlist hits* { > gen temp=`x' > replace `x'=. > egen tot_`x'=rowtotal(hits*) > replace `x'=temp > drop temp > } > > My question is > > 1. since string limit is 244, what is it about extended function subinstr that makes string limitation non issue. Does extended function increase the acceptable string length which I think is unlikely? > > 2. The code without subinstr works and again, it sounds like string limitation is a non issue. Again, is the code increasing the accepateble length of the string?? > > 3. when I use length command to find the length of the string in stata12, I get unrecognized command. Any idea. > > > * > * 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/ * * 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/

**References**:**st: work with larger string length***From:*tashi lama <[email protected]>

**st: RE: work with larger string length***From:*Nick Cox <[email protected]>

- Prev by Date:
**st: The early registration deadline for the The Modern Modeling Methods (M3) conference is approaching.** - Next by Date:
**Re: AW: AW: st: error message "too many weights"** - Previous by thread:
**st: RE: work with larger string length** - Next by thread:
**st: Questions relating to cases selection** - Index(es):