You cannot change a variable's type. You can make a NEW variable if you want. You could then change the names of the variables so the new variable uses the same name as the old variable.
PROC FORMAT has nothing to do with changing a variable's type. In fact the actions of PROC FORMAT have nothing to do with variables at all. They are for defining FORMATs and INFORMATs.
A FORMAT is special instructions on how to convert values into text. An INFORMAT is special instructions for how to convert text into values.
A character FORMAT converts text values to text. A numeric FORMAT converts numeric values to text. A numeric INFORMAT converts text to a number. A character INFORMAT converts text to other text.
The only way to use either of those to help with converting strings like 'male' into numbers like 1 would be to make a numeric INFORMAT. Your code is making a character FORMAT.
And then you don't even TRY to use what you made to CONVERT the variable. All you appear to do is try to ATTACH the format to a variable so that it will be DISPLAYED in a different way.
To use an INFORMAT() to make a numeric value from a character string you need to use the INPUT() function or the INPUT statement.
So if your existing variable is named GENDER and has values of 'male' or 'female' you could do something like this to make a new numeric variable named SEX that has values of 1 or 2.
proc format;
invalue gender
'male' = 1;
'female' = 2
;
run;
data want;
set have;
sex = input(gender,gender.);
run;