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


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

Re: st: Macro parsing question.


From   Amadou DIALLO <stata.diallo@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Macro parsing question.
Date   Thu, 14 Feb 2013 20:25:02 +0100

Many thanks Nick. Yes, I need this in a loop within a more complicated
code. I just tried to provide a simplified example. I need to sleep to
ease my headache.
I wish you all good night.

2013/2/14, Nick Cox <njcoxstata@gmail.com>:
> I am pleased that you seem to have worked this out. You may want to
> look at the stuff under -help macrolists-.
>
> Nick
>
> On Thu, Feb 14, 2013 at 7:00 PM, Amadou DIALLO <stata.diallo@gmail.com>
> wrote:
>> Jeph, Nick,
>> You are alright, I indeed didn't know what I was doing. This shows why
>> sleeping is indeed important :-).
>> The good code is:
>>
>> loc list1 a
>> loc list2 a b c
>> foreach i of loc list1 {
>> foreach k of loc list2 {
>>   if "`k'" == "`i'" local d = cond("`k'" == "`i'", "%", "Value")
>> }
>> }
>> di "`d'"
>>
>>
>>
>> thx
>>
>> 2013/2/14, Jeph Herrin <stata@spandrel.net>:
>>> Got it.
>>>
>>> On 2/14/2013 1:27 PM, Nick Cox wrote:
>>>> That line of code which I wrote earlier  is what Amadou's earlier
>>>> example boils down to.
>>>>
>>>> It is not a suggestion for what Amadou should use, and cannot be,
>>>> because
>>>>
>>>> 1. Amadou has implied that he does not want that result.
>>>>
>>>> 2. I don't know what Amadou really wants to do. He hasn't described
>>>> the problem he wants to solve.
>>>>
>>>> Nick
>>>>
>>>> On Thu, Feb 14, 2013 at 6:15 PM, Jeph Herrin <stata@spandrel.net>
>>>> wrote:
>>>>>
>>>>>
>>>>> On 2/14/2013 4:55 AM, Nick Cox wrote:
>>>>>>
>>>>>> Should be
>>>>>>
>>>>>> local d = cond("a" == "c", "%", "Value")
>>>>>>
>>>>>
>>>>> Note the condition is never true. Maybe you mean:
>>>>>
>>>>>   local d = cond("`k'"=="a", "%","Value")
>>>>>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
>


-- 
Amadou B. DIALLO, PhD.
Senior Economist, AfDB.
a.b.diallo@afdb.org
+21671101789
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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