BookmarkSubscribeRSS Feed
Calcite | Level 5



So i converted numeric variables into categorical variable.

By far when i check my temporary data called 'forreg' i can see 'Male' equals 1 for Gender.


But When i tried to plot PROC REG it still doesn't allow me to plot

and gives me error, saying:


150 data forreg;
151 set new;
152 KEEP Exam Assign Gender;
153 IF Gender='Male' then Gender=1; Else Gender=0;
154 run;

NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
153:30 153:45
NOTE: There were 146 observations read from the data set WORK.NEW.
NOTE: The data set WORK.FORREG has 146 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds

156 TITLE1 'Scatter';
157 PROC REG data=forreg;
158 MODEL Exam = Assign Gender /VIF;
ERROR: Variable GENDER in list does not match type prescribed for this list.
NOTE: The previous statement has been deleted.
159 RUN;

WARNING: No variables specified for an SSCP matrix. Execution terminating.
NOTE: PROCEDURE REG used (Total process time):
real time 0.08 seconds
cpu time 0.03 seconds


How can i plot PROC REG, using my converted dummy variables?


And here is my code

data forreg;
  set new;
  KEEP Exam Assign Gender;
IF Gender='Male' then Gender=1; Else Gender=0;

TITLE1 'Scatter';
PROC REG data=forreg;
MODEL  Exam = Assign Gender /VIF;

Opal | Level 21

Once a variable is character, it never changes to become numeric.  As the note in your log indicated, GENDER is still character after these statements:


if gender='Male' then gender=1; else gender=0;


It would be easy enough for you to verify that result by running a PROC CONTENTS on the result.


You can create a new variable:


if gender='Male' then gender_num=1; else gender_num=0;


You can even end up with a numeric variable named GENDER:


drop gender;

rename gender_num=gender;


But the original GENDER variable remains character for the duration of its existence.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 2 in conversation