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 identify a string as a variable?
From
Maarten Buis <[email protected]>
To
[email protected]
Subject
Re: st: How to identify a string as a variable?
Date
Wed, 10 Oct 2012 08:41:53 +0200
On Wed, Oct 10, 2012 at 5:39 AM, Nobuaki Michihata wrote:
>> I'm looking for the way to identify a text string as a variable.
>>
>> Here is an example.
>> .clear
>> .sysuse auto
>> . di price[1]
>> 4099
>> . di ("p"+"rice"+"[1]")
>> price[1]
>>
>> On the last command, I need "4099", not "price[1]".
>> Is there any string function to identify a string as a variable's name?
>> I'm looking for the way to identify a text string as a variable.
>>
>> Here is an example.
>> .clear
>> .sysuse auto
>> . di price[1]
>> 4099
>> . di ("p"+"rice"+"[1]")
>> price[1]
>>
>> On the last command, I need "4099", not "price[1]".
>> Is there any string function to identify a string as a variable's name?
--- On Wed, Oct 10, 2012 at 12:23 PM, [email protected] wrote:
> This might get you started.
>
> local a = "p" + "rice" + "[1]"
> disp `a'
Alternatively the following will work as well:
disp `= "p" + "rice" + "[1]" '
By surrounding an expression with -`=- and -'- you force that the
expression is evaluated.
-- Maarten
---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany
http://www.maartenbuis.nl
---------------------------------
*
* 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/