Your question is answered at -help macro-, as already indicated.
Nick
On Tue, Jan 22, 2013 at 12:12 AM, Dr. Yu Chen <profyuchen@gmail.com> wrote:
> I was reading this thread and found it interesting. Since A is a
> scalar (not a macro), what does `=A' do? More specifically, what does
> the equal sign and the single quotes do?
> Where can I find the documentation for this usage (i.e., the equal
> sign and the single quotes)?
> Thanks,
>
> Yu Chen
>
>
>
> On Sun, Jan 20, 2013 at 8:46 AM, Nick Cox <njcoxstata@gmail.com> wrote:
>>
>> sample `=scalar(A)', count
>>
>> will ensure that -sample- sees the value of scalar A because the
>> evaluation
>>
>> = scalar(A)
>>
>> takes place before -sample- gets to work. See -help macro- under
>> expansion_optr.
>>
>> The -scalar()- ensure no clash with variable names starting with "A".
>>
>> Nick
>>
>> On Sun, Jan 20, 2013 at 2:27 PM, Maisie Harris <mjh275@georgetown.edu>
>> wrote:
>> > I am running a loop of code in which I'd like to use the sample
>> > command, but instead of stating the specific number I want to sample
>> > I'd like to refer to a previously defined scalar.
>> >
>> > A simplified version of what I'm trying to do is:
>> >
>> > scalar A=5
>> > sample A, count
>> >
>> > However, when I run the code it says that it finds A when it is
>> > expecting a number. Is there a simple way to do this? Do I need to
>> > redefine the scalar somehow?
>> *
>> * 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/
*
* 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/