The panel data I have is to analyse firms' problems. Now, the following table shows the basic information I am going to use.
Basically, if the selling prices are at least or higher than $5, it is considered as the high-priced products; otherwise is low-priced products.
Here, the data records the selling information of all firms within two years. Another default setting is that "month" is a string variable currently.
I would like to calculate the average monthly high/low prices based on firms' code without missing data.
year | month | firm_code | selling prices | high price | low price | average high prices | average low prices | desired average high prices | desired average low prices |
2016 | mar | A | 6.7 | 6.7 | . | 6.7 | 3 | 6.7 | 3 |
2016 | mar | A | 3 | . | 3 | 6.7 | 3 | 6.7 | 3 |
2016 | mar | T | 2 | . | 2 | . | 2 | x1 | 2 |
2016 | apr | W | 2.3 | . | 2.3 | 5.1 | 2.3 | 5.1 | 2.3 |
2016 | apr | T | 3.5 | . | 3.5 | . | 3.5 | x1 | 3.5 |
2016 | apr | W | 5.1 | 5.1 | . | 5.1 | 2.3 | 5.1 | 2.3 |
2017 | mar | W | 2.3 | . | 2.3 | . | 2.35 | z1 | 2.35 |
2017 | mar | T | 9 | 9 | . | 9 | . | 9 | z2 |
2017 | mar | A | 7.8 | 7.8 | . | 7.8 | . | 7.8 | z3 |
2017 | mar | W | 2.4 | . | 2.4 | . | 2.35 | z1 | 2.35 |
2017 | apr | A | 5 | 5 | . | 5 | . | 5 | z3 |
2017 | apr | W | 1 | 7 | . | 7 | . | 7 | 2.35 |
May I know how do I get that?
Don't hesitate to comment if any unclear. Thanks in advance.

0 Response to How to fill in last-month selling price of each firm based on year and month?
Post a Comment