On 2003-10-03, Alex ([email protected]) wrote:
> Dear Statalisters,
> I am trying to make linear combinations of variables after a regression.
> I need to save the estimated linear combs and the variance matrix for later
> hypothesis testing, so I can't just use lincom - it doesn't save results
> in enough detail.
> I don't understand what is wrong with this code:
> /* program snippet for manual lincom */
> #delimit ;
> capture program drop coefdiff;
> program define coefdiff;
> args prefix yst yend;
> constraint drop _all;
> local count=0;
> for each y of numlist `yst' / `yend' {;
> local count = `count' + 1;
> if `y' == 1984 {;
<rest of code omitted>
I think the problem is that the line
for each y of numlist `yst' / `yend' {;
should instead read
foreach y of numlist `yst' / `yend' {;
Notice there is no space between "for" and "each". Alex is using the
syntax for the -foreach- statement, but because there is a space between
"for" and "each" in his code, Stata is parsing the syntax as if it were
the older -for- command.
-- Brian
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/