[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: modifying a macro containing variable names (problem solved)

From   "Nick Cox" <>
To   <>
Subject   RE: st: modifying a macro containing variable names (problem solved)
Date   Mon, 10 Mar 2008 09:33:51 -0000

To see what macros you have created, use -mac li-. 

-di- (-display-) evaluates macros and then shows the results. 
So it shows not what macros are, but what Stata sees when they are

The difference was behind your bug here. 


Jeremy Reynolds

Your code worked flawlessly.  Many thanks, Maarten.

Maarten buis wrote:
> I started by recreating your error messages and thus created the
> $ivlist, but than in my solution changed it into a local. I did not
> change that everywhere,  but because the global still hang around, I
> did not get an error message. The correct code should be: 
> *----------------- begin example ------------------
> sysuse auto, clear
> reg mpg displacement turn gear_ratio
> local ivlist "displacement turn gear_ratio"
> foreach var of varlist `ivlist' {
> 	local list1 : list ivlist - var
> 	di "`list1'"
> 	local numvars : word count (`list1')
> 	adjust `list1', xb by(foreign)
> 	sum `list1'
> }
> *-------------- end example -----------------------

*   For searches and help try:

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