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

st: re: saved local macro

From   Kit Baum <>
Subject   st: re: saved local macro
Date   Fri, 31 Oct 2008 08:30:44 -0400

< >
Martin is correct in suggesting that you should return a scalar. But if you work with macros, note that macros are _always_ strings. They may contain nothing but numbers, and Stata is smart enough to evaluate them as numbers in context:

program cu7, rclass
local numd 1
return local numd =`numd'

local foo = `r(numd)' + 1
di "`foo'"

If you display r(numd), you get "1", which is the value to which r(numd) is aliased. If you speak of it as `r(numd)', you are explicitly directing Stata to replace r(numd) in the -local- command with its value, and then execute the command. That works fine.

Kit Baum, Boston College Economics and DIW Berlin
An Introduction to Modern Econometrics Using Stata:

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index