Site icon Stata.Professor : Your Partner in Research

How to find weighted average mean with asgen using the IF condition

Hey Prof. Shah, I have another short question regarding the asgen command. my if condition ( if Ranking_EU==1) is only observed in December. What I want is to calculate the mean for the whole year. So, ideally use every company in the year and their respective return for every month, which are ranked with a 1 in December. As I am thinking, what your command really does, I want to ask if with this command: bysort Date: asgen MW_return_EU1 = Return if Ranking_EU==1, w(MV_EU1) I think I only consider the returns in December, because from January to November I do not have a ranking. Thank you if you can help me out. Best Dan
Exit mobile version