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: -local- problem


From   Phil Clayton <philclayton@internode.on.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: -local- problem
Date   Thu, 17 Nov 2011 06:52:09 +1100

Use `m' rather than 'm'. See -help quotes-

Incidentally, if the -gen- command is coming straight after the command that's returning the mean and sd (eg -summarize-) you could bypass the locals altogether:

summarize myvar
gen affiloui2=(affiloui - r(mean))/r(sd)

Phil

On 17/11/2011, at 1:37 AM, saqlain raza wrote:

> Hello colleagues, I am in try to make a -local- with the following command:
> 
> 
> local m=r(mean)
> local sd=r(sd)
> 
> Then I try to generate a variable. 
> 
> gen affiloui2=(affiloui - 'm')/'sd'
> 
> but it gives me an error 
> 
> 'm' invalid name
> r(198);
> 
> I have tried with double quotes but even then it is not working. How this problem can be solved? Is there any problem in making -local-? Note that affiloui is already a variable in the database.
> 
> Saqlain RAZA
> PhD Student (saqlain.raza@toulouse.inra.fr)
> 
> *
> *   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