Hi everybody
I am looking to log transform a variable that measures salary. However, some observations are 0, which makes the log transformation erroneous. I have read that you can add 0.0001 to all observations and then transform. However, it is not working as values of 0.0001 become missing. My goal is to calculate the percentage change over time for a treatment and control group.
Here is some code and an example dataset:
I am looking to log transform a variable that measures salary. However, some observations are 0, which makes the log transformation erroneous. I have read that you can add 0.0001 to all observations and then transform. However, it is not working as values of 0.0001 become missing. My goal is to calculate the percentage change over time for a treatment and control group.
Here is some code and an example dataset:
Code:
sort id time replace salary = 0 if id == 1 & time == 99 // just to create the issue that I am facing in my main dataset gen ln1_salary = salary+0.00001 bro id tim salary ln1_salary replace ln1_salary = ln(salary)
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id time treatment salary gender) 8 103 0 40000 0 8 99 0 40000 0 17 97 1 40000 0 9 98 0 40000 0 18 103 1 35000 0 18 98 1 40000 0 14 99 0 40000 0 17 99 1 40000 0 12 97 1 40000 0 5 100 1 40000 0 12 98 1 40000 0 14 101 0 40000 0 14 98 0 40000 0 18 100 1 40000 0 17 98 1 40000 0 9 101 0 40000 0 17 100 1 40000 0 12 99 1 40000 0 5 102 1 35000 0 12 102 1 35000 0 17 102 1 35000 0 12 101 1 35000 0 13 100 0 40000 0 13 102 0 40000 0 8 98 0 40000 0 5 103 1 35000 0 18 102 1 35000 0 5 97 1 40000 0 12 100 1 40000 0 17 103 1 35000 0 9 102 0 40000 0 13 103 0 40000 0 8 102 0 40000 0 5 98 1 40000 0 9 99 0 40000 0 14 100 0 40000 0 13 99 0 40000 0 8 100 0 40000 0 14 97 0 40000 0 9 103 0 40000 0 17 101 1 35000 0 13 98 0 40000 0 13 97 0 40000 0 14 103 0 40000 0 5 101 1 35000 0 8 97 0 40000 0 12 103 1 35000 0 18 101 1 35000 0 8 101 0 40000 0 14 102 0 40000 0 5 99 1 40000 0 9 100 0 40000 0 18 99 1 40000 0 13 101 0 40000 0 9 97 0 40000 0 18 97 1 40000 0 2 98 1 30000 1 1 102 1 25000 1 20 98 1 30000 1 2 97 1 30000 1 15 97 0 30000 1 19 98 1 30000 1 16 101 0 30000 1 1 100 1 30000 1 20 103 1 25000 1 19 101 1 25000 1 2 101 1 25000 1 19 103 1 25000 1 2 99 1 30000 1 1 103 1 25000 1 15 99 0 30000 1 20 102 1 25000 1 6 97 0 30000 1 7 103 0 30000 1 1 101 1 25000 1 15 100 0 30000 1 16 97 0 30000 1 20 100 1 30000 1 1 97 1 30000 1 6 101 0 30000 1 20 97 1 30000 1 19 97 1 30000 1 16 99 0 30000 1 16 103 0 30000 1 2 100 1 30000 1 16 100 0 30000 1 15 101 0 30000 1 15 102 0 30000 1 1 99 1 30000 1 7 100 0 30000 1 15 103 0 30000 1 7 98 0 30000 1 16 98 0 30000 1 2 102 1 25000 1 7 97 0 30000 1 6 100 0 30000 1 15 98 0 30000 1 7 99 0 30000 1 1 98 1 30000 1 16 102 0 30000 1 end
Comment