Step 1: Meaning of “but for” here.
“But for” = “except for” / “if it were not for” — introduces the reason or condition preventing something. This makes “but” part of the prepositional phrase “but for.” Step 2: Grammar classification.
In “but for cancer,” the word “but” functions as a preposition within the fixed phrase, governing the noun “cancer.”
\[
\boxed{\text{(B) Preposition}}
\]