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 on April 23, and its replacement, statalist.org is already up and running.


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

st: use of subinstr


From   tashi lama <ltashi32@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: use of subinstr
Date   Thu, 22 Mar 2012 20:17:35 +0000

Hello All, 

I have a very large dataset with about 51 variables. I would like to write a program which would calculate rowmean but leaving one variable each time. Here is my code

  

ds var*
local varlist `r(varlist)'
foreach x of local varlist {
local varlist_new=subinstr("`varlist'", "`x'","",1)
di "`varlist_new'"
egen ave_`x'=rowmean(`varlist_new')
}


 

 

This works great if my variables are less than 244 char. However, my variables are way bigger than 244 chars. What option do I have now? My dataset has missing values if that matters. 

 

Thanx,

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