Dear statalist

I have a problem using margins on stata command.
I'm doing some research related to the effect of election on corporate investment.

I generate control variables called victory (which is defined as the numbers of vote that the winner got from the election) and difofvote (vote difference between the winner and the running-up).
My problem is that I want to create another dummy variable called "Close" that sets to one if the vote difference(difofvote) between the winner and the running-up is below the 25th percentile of the (victory) margin distribution. I'm new to use margins, so I'm not sure.

Here are my codes:
reg difofvote victory, allbaselevels
margins, dydx(victory) at((p25) victory)


Can anyone here help me please.
Thank you!