The datasheet of the proximity sensors has a schematic how to interface this sensor with a 5V input. The schematic has the information that the resistorvalues are for a supply-voltage fo 12V

As a general advise:
If you leave standard consumer USB-products like microcontrollers and electronic components you have to take care of much more details than just
"does the plug fit into the socket?"
As you have drawn it you connected the output of the proximity-sensor directly to the arduino-IO-pin.
Depending on the exact internal circuitry of the proximity-sensor you might have damaged your arduino. Might it is not a must. The schematic shows how to interface to micrcontrollers
The resitsors have values 150k and 100k. These values are used for a 12V supply.
If you supply with 9V the value on one resistor must be changed to again get a 5V signal from this small cicuit called voltage-divider.
And this is one of the details you have to care about as this is not a standard consumber USB-device.
Do you have a digital multimeter?
If not I highly recommend buying one. Almost any digital multimeter in the $8 to 15$ range will do.
If you can afford to spend a little more money I recommend a digital multimeter which can
additionally to the standard voltage, ampere Ohms
measure
- 10A (most of them can only 2A)
- frequency up to 1 MHz
- % duty-cycle
- capacitance
- forward-voltage of diodes
As you have posted it without any load-resistor I guess nothing is damaged yet
If you use a single load-resistor the 9V which is way too much ! would damage the Arduino
You will have to use a voltage-divider to get 5V

Now the question is what value shall the resistor R1 have?
You can use this online-calculator to calculate the value
best regards Stefan

