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

st: RE: a simple macro problem

From   "Martin Weiss" <>
To   <>
Subject   st: RE: a simple macro problem
Date   Fri, 27 Jun 2008 20:57:13 +0200

foreach gov in any gov1 gov2{
	reg sales `gov' totalassets

Not sure where the mistake is in yours, probably something with the local
"dvar" being unable to hold the string you are offering it because the `j'
must be evaluated the moment you define "dvar"...

Martin Weiss

Diplom-Kaufmann Martin Weiss
Mohlstrasse 36
Room 415
72074 Tuebingen

Fon: 0049-7071-2978184




-----Original Message-----
[] On Behalf Of Martin Wang
Sent: Friday, June 27, 2008 8:53 PM
Subject: st: a simple macro problem

Dear all,

I have the following macro, but it doesn't work as I expected:
I have gov1, gov2

and I wrote:

local dvar=" gov`j' totalassets"
 local j=1

 while `j'<3{
  reg sales `dvar'
  local j = `j' + 1

I expect this will run sales= gov1 totalassets and  sales= gov2 totalassets,
but only the first one ran twice, no second one. Anyone could help me out?

Many thanks!


*   For searches and help try:

*   For searches and help try:

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