In this simple example, $_POST["whatever"] would not be displayed so as I understand it, sanitizing it for XSS is unnecessary.
On the other hand, then the following would be correct...
if ($_POST["whatever"] == "Y"){
echo htmlentities($_POST["ToBeDisplayed"]));
}
Thanks