Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: forval predict values into same column


From   Michael Bondegård <[email protected]>
To   [email protected]
Subject   st: forval predict values into same column
Date   Mon, 24 Jan 2011 21:14:57 +0100

Hello,
1. question 1

I wonder how to make this
forval i=1/6 {
regress Y1 X1 X2 if GROUPID ==`i'
predict Y1HAT if e(sample)
}

When i do this it tells me  Y1HAT already defined (so it stops after
second run, return just values first time)

I know that i can do this:
forval i=1/6 {
regress Y1 X1 X2 if GROUPID ==`i'
predict Y1HAT_`i' if e(sample)
}

As you see i add same number to the predictor that way i can go trough
this problem but what i want is to put the prediction in same column
from the start.

This is because the GROUPID is diffrent for each prediction so it wont
overwrite anything once it input the prediction values into it.

2, question 2
How to make return a maximum value for the GROUPID, as you see in the
example above the forval runs 6 timas (6 is the max in GROUPID)

My question is, is there any way to make the similar to this wish:
forval i=1/MAX(GROUPID)

I been looking for the right answer but no luck:(

Thanks for help
best regards Mike
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index