Bookmark and Share

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]

st: use of subinstr


From   tashi lama <[email protected]>
To   <[email protected]>
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index