Help with Stata

Hi Guys,

I'm trying to run a regression on price of online books against a set of book dummy variables (corresponding to the title of the book) and the book condition. I created the book dummy variables by:

tab bnum, g(bdummy)

where 'bnum' is a unique identifier for a title of a book. There are 400 bdummy variables and around 8000 thousand observations so we have numerous observations with the same title.

I next ran the regression:
reg oprice ocond bdummy*, noconstant.

where oprice is the price of the book and ocond is the condition of the book. I'm interested in grabbing the coefficients on the dummies from the previous regression and merging it to my existing dataset. However, if I use the command:

matrix b = e(b)'
svmat b
summ b1

I get a new column b1 in my dataset with all the regression coefficients but it doesn't group them by the variable 'bnum'. In other words, observations with the same title should have the same dummy coefficient but Stata just lists each unique coefficient so many observations are paired with the wrong dummy coefficient. Therefore, instead of getting 8000 coefficients with 400 unique coefficients, Stata just lists the 400 unique coefficients so I can't merge the dataset. Is there a way to fix this problem?

Hey there,

It seems to me that what you want to do is to obtain the predicted value with ocond set equal to 0. So what you should do is:

reg oprice ocond bdummy*, noconstant.
replace ocond = 0
predict pdummy, xb

and then pdummy will be the variable you want to obtain.

Hope this helps,