Ryan and Richard,
Thank you so much for your good answers. Very useful indeed.
Best,
On Wed, Feb 20, 2013 at 10:53 AM, Ryan Stevens <stevrl7@gmail.com> wrote:
> This may be too much looping but if it were me, I'd probably do
> something as follows:
>
> local N _N
> forval i=1/`N'{
> if(`=x[`i']' == 50){
> local y`i' `=y[`i']'
> }
> }
>
> On Wed, Feb 20, 2013 at 10:43 AM, Pablo Bonilla
> <pablo.bonilla1234@gmail.com> wrote:
>> Dear Statalist users:
>>
>> Sometimes I need to save in a local a specific value of a variable and
>> I cannot do it because creating a local does not support “if” neither
>> “in” conditions. For instances, let’s suppose that I have two
>> variables: “x” and “y”. Variable “x” goes from 1 to 100 and “y” is a
>> random vector. Now, how can I save in a local the value of “y” when
>> “x” is, for example, 50? In other words, I would like to do something
>> like this:
>>
>> local y50 = y if x == 50
>>
>> I know that is not possible and it is actually a “heresy” in Stata
>> language but it might give you an idea of what I need.
>>
>> Thank you so much for your help and any idea is more that welcome.
>>
>> Best
>>
>>
>> ----
>>
>> Pablo Bonilla
>>
>> *
>> * 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/
>
> *
> * 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/
--
----
Pablo Bonilla
*
* 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/