Construct a dichotomous variable + calculate YOY growth with a dataset with multiple companies and multiple years.

Hi everyone,

Currently I have a database, that I want to use to create a dichotomous variable that looks as follows:

1= big bath
0= no big bath

I can determine big bath as follows:
If there is a contraction in Year on Year sale, we expect a goodwill impairment (gdwlia). The cash flow is considered low if it is lower than the median change.

My database has data of the period 2005-2018 and the most left column is a unique company key.
I have the following data:
image

Can you guys help me with the following two questions:

  1. Which function can I use to calculate the year on year growth per company per year in the dataset? (I tried to do this by creating subsets for every year, but I am not able to add another variable (year on year growth via formula "(year new$sales - year old$sales)/yearold$sales.

  2. Is If.else the right formula to use for this dichotomous variable? ( if year on year sales contract, and impairment is higher then median impairment for that year, then 1. If this criteria is not met, then 0).

Thank you in advance for your help!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers. It's time consuming to reverse engineer problems

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.