Statalist


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

RE: st: Counting commas in a string variable


From   Roy Wada <[email protected]>
To   <[email protected]>
Subject   RE: st: Counting commas in a string variable
Date   Thu, 2 Jul 2009 22:46:20 -0700

 
> gen comma = length(trim(var1))-length(trim(subinstr(var1,",","",.)))
 
On a second thought, you probably want to -trim( )- before applying 
-subinstr( )-.
 
gen comma = length(trim(var1))-length(subinstr(trim(var1,",","",.)))
 
Roy
 
_________________________________________________________________
Lauren found her dream laptop. Find the PC that’s right for you.
http://www.microsoft.com/windows/choosepc/?ocid=ftp_val_wl_290
*
*   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