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]
Re: st: How to separate multiple word assignments to a macro
From
Thomas Jacobs <[email protected]>
To
[email protected]
Subject
Re: st: How to separate multiple word assignments to a macro
Date
Fri, 9 Apr 2010 22:24:31 -0500
Dear Michael,
Thanks very much, that was EXACTLY what I was trying to do. Most helpful!
Tom
On Fri, Apr 9, 2010 at 10:07 PM, Michael Norman Mitchell
<[email protected]> wrote:
> Dear Tom
>
> I wonder if this would do the trick for you...
>
> local TreasRatesDisplay `""5 Yr Treas Rate" "10 Yr Treas Rate" "20 Yr Treas
> Rate""'
>
> You could extract the three pieces like this...
>
> local a : word 1 of `TreasRatesDisplay'
> local b : word 2 of `TreasRatesDisplay'
> local c : word 3 of `TreasRatesDisplay'
>
> And then you can display the three pieces like this
>
> . di "The first word is `a'"
> The first word is 5 Yr Treas Rate
>
> . di "The second word is `b'"
> The second word is 10 Yr Treas Rate
>
> . di "The third word is `c'"
> The third word is 20 Yr Treas Rate
>
> The key is using the -compound double quotes- which start with `" and end
> with "' . These are like super duper quotes that can hold a quoted string,
> and Stata understand that each quoted pair is a different -word-.
>
> You can even extact the number of words using the "word count" function...
>
> . local wc : word count `TreasRatesDisplay'
> . di `wc'
> 3
>
> I hope this is helpful.
>
> Michael N. Mitchell
> See the Stata tidbit of the week at...
> http://www.MichaelNormanMitchell.com
>
> On 2010-04-09 4.45 PM, Thomas Jacobs wrote:
>>
>> I am trying to create a macro of readable variable names for later
>> output in multiple tables. Thus, the number of variable names will
>> change. For example assume I have a case with three values such as
>>
>> 5 Yr Treas Rate, 10 Yr Treas Rate, 20 Yr Treas Rate
>>
>> which I wish to assign to the macro TreasRatesDisplay
>>
>> Is there any way to do this and end up with just 3 values in the macro
>> where each value may have embedded spaces? Thanks.
>>
>> Tom
>>
>> --
>> Thomas Jacobs
>> *
>> * 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/
>>
>
> *
> * 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/
>
--
Thomas Jacobs
*
* 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/