Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: work with larger string length


From   tashi lama <ltashi32@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: work with larger string length
Date   Tue, 27 Mar 2012 14:57:51 +0000

Hellow All, 

       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. 

 

 

 

Thanks so much...

Tashi 		 	   		  
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index