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, is already up and running.

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

RE: st: string question

From   Nick Cox <>
To   "''" <>
Subject   RE: st: string question
Date   Tue, 7 Jun 2011 14:35:47 +0100

If -n- is the name of a scalar defined by 

. scalar n = <whatever>

then it should be evaluated on the fly by something like 

. local fivefrogs : di _dup(`= scalar(n)') "frog"

I think most experienced Stata programmers tend to use locals to hold something like that. 



Many thanks. I have one follow up question.

I would like to call a scalar in _dup()  like

. local fivefrogs : di _dup(`n') "frog"

For some reason this does not work. How can this be done?

On 07/06/2011 09:37, Nick Cox wrote:

> . di _dup(5) "frog"
> frogfrogfrogfrogfrog
> . local fivefrogs : di _dup(5) "frog"
> . di "`fivefrogs'"
> frogfrogfrogfrogfrog

On Tue, Jun 7, 2011 at 9:22 AM, Thomas<>  wrote:

>> I need to define macros with a few words that are repeated many times like:
>> global macro a ..... b .....
>> Is there any string function that allows to to repeat a word x times?

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index