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

 

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 362 views
  • 0 likes
  • 2 in conversation