Thanks Martin
One quick (and rather rookie) question: when I am using r-class resule
(such as r(max) ) is there a way to store this value into a constant
variable and then use that variable instead ?
Thanks again for FAQ.
On Mon, Nov 9, 2009 at 5:58 PM, Martin Weiss <[email protected]> wrote:
>
> <>
>
> Sure, this is an "implicit" loop, sorry about that!
>
> You would loop over the distinct values of variables as in the FAQ cited
> earlier...
>
>
> HTH
> Martin
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Kushan Thakkar
> Sent: Montag, 9. November 2009 23:53
> To: [email protected]
> Subject: Re: st: using postfile in a loop
>
> I meant to say that if I have the following data,
>
> cusip date ticker prc
>
> If I do gen newvar, it would automatically do it for all the
> datapoints (hence gen command has a built-in loop).
>
> However, I want to know how can I do the same by using an actual
> foreach loop that loops over cusip or data variable.
>
> Thanks
>
> On Mon, Nov 9, 2009 at 5:40 PM, Martin Weiss <[email protected]> wrote:
>>
>> <>
>>
>> http://www.stata.com/support/faqs/data/foreach.html
>>
>>
>>
>> What do you mean by " gen variable with built-in loop"?
>>
>> HTH
>> Martin
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Kushan Thakkar
>> Sent: Montag, 9. November 2009 23:34
>> To: [email protected]
>> Subject: Re: st: using postfile in a loop
>>
>> Thanks everyone for calling me out on the no loop part.
>>
>> On a different note, how can I loop on a single variable ? For
>> example, let's say if I wanted to loop over the date variable and then
>> over the cusip variable, how would I go about doing this? I understand
>> that there is no need to explicitly create loop since I can use gen
>> variable with built-in loop. However, I want to do this so that I can
>> understand how loops and postfile work with each other.
>>
>> Thanks.
>>
>> On Mon, Nov 9, 2009 at 5:14 PM, Maarten buis <[email protected]>
>> wrote:
>>> --- On Mon, 9/11/09, Kushan Thakkar wrote:
>>>> I have a dataset the contains the following data:
>>>>
>>>> cusip ticker date prc ....(few more variables).... RminusI
>>>>
>>>> I need to isolate data points for which RminusI is less
>>>> than its first decile and then post these data points in a
>>>> different file.
>>>
>>> This is not a case for -postfile- or a loop. In the example
>>> below nlsw88.dta is your master data, grade is your id variable,
>>> and wage is your RminusI variable.
>>>
>>> *---------- begin example --------------
>>> sysuse nlsw88, clear
>>> bys grade: egen lb = pctile(wage), p(10)
>>> keep if wage < lb
>>> *------------ end example --------------
>>> ( For more on how to use examples I sent to statalist see:
>>> http://www.maartenbuis.nl/stata/exampleFAQ.html )
>>>
>>> Hope this helps,
>>> Maarten
>>> --------------------------
>>> Maarten L. Buis
>>> Institut fuer Soziologie
>>> Universitaet Tuebingen
>>> Wilhelmstrasse 36
>>> 72074 Tuebingen
>>> Germany
>>>
>>> http://www.maartenbuis.nl
>>> --------------------------
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> *
>>> * 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/
>>
>>
>> *
>> * 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/
>
>
> *
> * 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/