I am trying to fit a cox proportional hazard model where all of my covariates are categorical except for one. I am planning to do a forward/backward model building but am wondering whether it is sound to include the covariates as a non-factor for the model building? Secondly, as the martingale residuals are used to assess if functional form of my covariates is correct, it makes no sense to transform my categorical data, so is it safe to build the model with the best categorical variables(as deemed by the model building) and then use the martingale residuals to determine the correct form for my continuous covariate?
If you're performing model selection, you don't need to temporarily cast your categorical predictors as numeric ones. Cast the variables so that they make your model easier to interpret. I'll flag this here too - there are a number of statistical problems with stepwise model selection which I'll let you familiarise yourself with.
However, from a practical perspective, just be wary of these automated methods accidentally including collinear predictors (which may impact the reliability of the model) as well as nuisance variables which don't make much real world sense. It's important to vet the variables you fire into automated stepwise procedures to avoid these kinds of problems.