After running a sum-command the mean is being saved as a scalar. r(mean) is that scalar. So in your case r(mean) is equal to the mean of Tradedattheend for product `i'.
I am trying to understand your code. I know what you're doing, but what does the r(mean)-command?
forvalues i=1(1)666 {
sum Tradedattheend if Prouctid==`i'
qui replace Tradedattheend=1 if r(mean)>0 & Productid==`i'
}
After running a sum-command the mean is being saved as a scalar. r(mean) is that scalar. So in your case r(mean) is equal to the mean of Tradedattheend for product `i'.
Englund, could plz take a look at another problem i face?
http://www.talkstats.com/showthread....cts?highlight=
I can't get what I want. I hope you could help me in the right direction. thx
I've been on leave but wanted to come back to this thread to make this comment - the above is NOT how to handle sorting on date. Instead you should convert your string date to a Stata formatted date using the date() function. For example:
gen mydate=date(Date, "MDY")
format %td mydate
Then you can sort on mydate, use mydate for time-series commands etc etc.
Thank you for your advice bukharin. Could you plz look at my other question?
http://www.talkstats.com/showthread....cts?highlight=
I am still struggling with this problem, can't really get what i want.
I hope you have an idea.
|
|