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: question about local and var[n]


From   "G. Dai" <dgecon@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: question about local and var[n]
Date   Tue, 25 Oct 2011 14:35:27 -0600

Thank you,Matt. It helps.

On Tue, Oct 25, 2011 at 12:25 AM, Matthew White
<mwhite@poverty-action.org> wrote:
> You probably want:
> local city = ID[1]
> not:
> local city ID[1]
> The latter just assigns the string "ID[1]" to `city'. -display
> "`city'"- will display "ID[1]" not "ny". The former, on the other
> hand, first evaluates the expression ID[1], THEN assigns the result to
> `city'. ID[1] will evaluate to "ny", which is then assigned to `city'.
> -display "`city'"- will display "ny".
>
> Hope that helps!
>
> Best,
> Matt
>
> On Tue, Oct 25, 2011 at 1:47 AM, G. Dai <dgecon@gmail.com> wrote:
>> Dear all,
>> I have one question about the use of local macros.
>> For example, assume the date
>>
>> ID     ny_price
>> ny      5
>> wa      4
>>
>> set obs 2
>> gen str ID=""
>> replace ID="ny" in 1
>> replace ID="wa" in 2
>> gen ny_price=4
>> replace ny_price=5 in 1
>>
>>
>> Then My question comes from the following differences:
>>
>>
>> . local city ny
>>
>> .
>> . replace `city'_price=100 in 1
>> (1 real change made)
>>
>>
>> However,
>>
>> . local city ID[1]
>> . di `city'
>> ny
>> . replace `city'_price=100 in 1
>> weights not allowed
>> r(101);
>>
>> Why?
>> thanks!
>> *
>> *   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/
>>
>
>
>
> --
> Matthew White
> Data Coordinator
> Innovations for Poverty Action
> 101 Whitney Avenue, New Haven, CT 06510 USA
> +1 434-305-9861
> www.poverty-action.org
>
> *
> *   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/


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