Endogeneity problem with a dummy variable I have a panel data model as following,
$$Y_{it}=intercept +B_1X_{it}+B_2Q_{it}+error_{it}$$   

where $i$ is for firm and $t$= time.

$Y$= trade credit demand, $X$= inventory cycle, as inventory moves faster firms demand more trade credit. On the other hand because trade credit means extra inventory, the cycle would be affected by it, too.

I know that the model suffers from endogeneity because $Y$ affects $X$ and in return $X$ affects $Y$. Would it be a valid procedure if I tried to work around this issue by assigning a dummy variable and not use $X$ in the analysis at all by calculating first yearly average for the cycle and assign 1 if a firm is above the average for that year and 0 if below it.  Maybe the code I am using may clarify any vagueness.

in the R code below.

mydata=mydata%&gt;%group_by(year)%&gt;%mutate(mean_x=mean(x)) 
mydata=mydata%&gt;%mutate(Dummy=case_when(X&gt;=mean_x~1, TRUE~0))


and the model becomes as following:

$$Y_{it}=intercept+B_1 Dummy+B_2 Q_{it}+error_{it}$$

I hope I am clear enough. thanks in advance!
No, 

I don't see how the dummy variable you are proposing would give you the same (or even similar) analysis as in the original model. 

I would recommend dealing with the endogeneity in another way. IV estimation, or one of the more recent methods, difference-in-difference, matching etc. One of the will be suitable.