Hi all,
I am new to this forum and also relatively new to the stata software package. I've been using it for several months now for an econometrics university course.
I am currently having some troubles getting the if function working. I am considering a dataset of motel occupancies while repairs are and aren't being undertaken. Effectively I am trying to generate an average of the motel occupancies while repairs aren't (repair=0) and when they are (repair=1) being undertaken.
My approach so far has been to generate the variable using the if function and then I was going to take the mean of this variable but I haven't succeeded in step 1 as yet.
My syntax looks like so:
generate motel0 = motel_pct if repair=0 (invalid syntax)
Then I would have followed with...
mean(motel0)
If anyone could point me in the right direction that would be much appreciated![Smile]()
Thanks all!
I am new to this forum and also relatively new to the stata software package. I've been using it for several months now for an econometrics university course.
I am currently having some troubles getting the if function working. I am considering a dataset of motel occupancies while repairs are and aren't being undertaken. Effectively I am trying to generate an average of the motel occupancies while repairs aren't (repair=0) and when they are (repair=1) being undertaken.
My approach so far has been to generate the variable using the if function and then I was going to take the mean of this variable but I haven't succeeded in step 1 as yet.
My syntax looks like so:
generate motel0 = motel_pct if repair=0 (invalid syntax)
Then I would have followed with...
mean(motel0)
If anyone could point me in the right direction that would be much appreciated

Thanks all!