Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Parse question.

From   Nick Winter <>
Subject   Re: st: Parse question.
Date   Thu, 22 Sep 2005 11:04:20 -0400

One approach is to use the macro extended function -subinstr-

For example:

. local junk : subinstr local loc ";" "" , all count(local num)

this will create the local junk, with all occurances of ";" replaced with "". You don't care about this, but it will also create the local called num which will contain the number of replacements.

-Nick Winter

At 10:30 AM 9/22/2005, you wrote:

Is there any way to count the number of occurence of a particular character in a
local or
global macro?
For example:
local loc (a mama baba).
I would like to count the number of occurences of "a" , in this case 5.
Or local loc "There; That; This)
I want to count the number of occurences of ";".
I am writing an ado for a work and I can't figure how to do it.
I have a look at macrolists but there is no mention of that case.
Any help will be greatly appreciated.
Best regards.
Amadou DIALLO.
* For searches and help try:
Nicholas J. G. Winter 607.255.8819 t
Assistant Professor 607.255.4530 f
Department of Government e
Cornell University w
308 White Hall
Ithaca, NY 14853-4601

* For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index