> 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/