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 at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: RE: -local- problem


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: -local- problem
Date   Wed, 16 Nov 2011 15:47:42 +0000

"Dots" are in Stata numeric missings.  

My code, like yours, presumes that r(mean) and r(sd) exist in memory as a result of some previous command, e.g. -summarize-. If that is not true then the result will be as you describe. 

Nick 
n.j.cox@durham.ac.uk 


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of saqlain raza
Sent: 16 November 2011 15:12
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: -local- problem

Thank you Nick.

gen affiloui2=(affiloui - r(mean))/r(sd) creates the variable but it do not show any values of the variable, it shows only dots (.). How could it be dealt with?
 
Saqlain RAZA
PhD Student (saqlain.raza@toulouse.inra.fr)




----- Original Message -----
From: Nick Cox <n.j.cox@durham.ac.uk>
To: "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Cc: 
Sent: Wednesday, November 16, 2011 3:50 PM
Subject: st: RE: -local- problem

This problem was explained yesterday. The opening and closing ticks should be different: 

`m' 

Note that in your example locals are unnecessary and just complicate the code: 

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

Nick 
n.j.cox@durham.ac.uk 

saqlain raza

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.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?searchhttp://www.stata.com/support/statalist/faqhttp://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/

*
*   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