Hi,
I want to create a variable using -cond()- as follows:
However, the new variable contains also a dummy equals to one when both power_p1 and power_p2 are missing, which I don't want.
Basically, if one of variable power_p1 or power_p2 is missing, it should contain 1.
But, if both are missing, it should take the value of 0, instead of 1 right now.
Thank you for your help.
Best,
Michael
I want to create a variable using -cond()- as follows:
Code:
gen tariff_2_more_15000_w = cond(tariff_2 == 1 & (power_p1 <=15000 | power_p2 <=15000), 1,0) replace tariff_2_more_15000_w = 0 if tariff_2 == 1 & (power_p1 >15000 | power_p2 >15000)
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long(power_p1 power_p2) float(tariff_2_more_15000_w tariff_2) 3300 . 0 1 3450 3450 1 1 2300 2300 1 1 3450 3450 1 1 3450 3450 1 1 2300 2300 1 1 5400 5400 1 1 3300 3300 1 1 3450 . 0 1 2300 2300 1 1 1725 . 0 1 3450 3450 1 1 3450 3450 1 1 3100 3100 1 1 1000 1000 1 1 3300 3300 1 1 2000 2000 1 1 2300 2300 1 1 3450 3450 1 1 3450 3450 1 1 4600 4600 1 1 1725 1725 1 1 3450 . 0 1 . . 0 1 2300 2300 1 1 3100 3100 1 1 3450 3450 1 1 6200 6200 1 1 2200 2200 1 1 2300 2300 1 1 2000 2000 1 1 3500 3500 1 1 2300 2300 1 1 2300 2300 1 1 2300 2300 1 1 2300 2300 1 1 2300 2300 1 1 2300 2300 1 1 3300 3300 1 1 3450 3450 1 1 3450 3450 1 1 3450 3450 1 1 3450 3450 1 1 1150 1150 1 1 5500 5500 1 1 2300 2300 1 1 3450 3450 1 1 3450 . 0 1 3450 3450 1 1 2300 2300 1 1 3100 3100 1 1 3450 3450 1 1 3450 . 0 1 3450 3450 1 1 3450 3450 1 1 3100 3100 1 1 3450 3450 1 1 5500 5500 1 1 3300 3300 1 1 3300 3300 1 1 2300 2300 1 1 4000 4000 1 1 2200 . 0 1 2300 2300 1 1 3500 3500 1 1 3450 3450 1 1 3450 3450 1 1 3100 3100 1 1 3400 . 0 1 3450 3450 1 1 2800 2800 1 1 3450 3450 1 1 3450 3450 1 1 2300 2300 1 1 2000 2000 1 1 3100 3100 1 1 2300 2300 1 1 13200 13200 1 1 3450 3450 1 1 2200 . 0 1 3450 3450 1 1 3300 3300 1 1 2300 2300 1 1 6200 6200 1 1 2300 2300 1 1 3300 3300 1 1 3400 3400 1 1 2300 2300 1 1 2300 2300 1 1 3450 3450 1 1 2300 2300 1 1 3450 3450 1 1 3450 . 0 1 3100 3100 1 1 3450 . 0 1 3450 3450 1 1 2300 2300 1 1 3000 3000 1 1 3450 3450 1 1 3450 . 0 1 end
However, the new variable contains also a dummy equals to one when both power_p1 and power_p2 are missing, which I don't want.
Basically, if one of variable power_p1 or power_p2 is missing, it should contain 1.
But, if both are missing, it should take the value of 0, instead of 1 right now.
Thank you for your help.
Best,
Michael
Comment