BookmarkSubscribeRSS Feed
SIMMII
Calcite | Level 5

Hi,

 

I'm trying to do a proc glmselect with all the variable interactions. However, I have a log error message telling me that the y variable does not match the type prescribed in the list. I know that it is because my y variable is a character variable (it is binary) while all the Xs are numeric. What code exactly should I use to convert this y variable into a numeric variable?

 

Screenshot 1: The log message

ps2-question1.PNG

 

Screenshot 2: The SAS code in question

 

ps2-question1.screenshot2.PNG

 

The list of variables and their attributes for dataset "ps2renamed" 

ps2-question1.screenshot3.PNG

 

Thank you! (Btw, I'm SAS On Demand for Academics)

1 REPLY 1
Patrick
Opal | Level 21

Something along the line of below sample code should do

data work.ps2renamed;
  x41=1;
  y='Yes';
  output;
  Y='No';
  output;
run;

proc format;
  invalue yn_char2num(upcase)
    'Y','YES' = 1
    'N','NO'  = 0
    other =.
    ;
run;

data work.ps2renamed;
  set work.ps2renamed(rename=(y=y_char));
  y=input(y_char,yn_char2num.);
  drop y_char;
run;

proc print data=work.ps2renamed;
run;

Patrick_0-1701404127155.png

Patrick_0-1701404215807.png