BookmarkSubscribeRSS Feed
glee217
Calcite | Level 5

Hi

 

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


155
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;
run;

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

1 REPLY 1
Astounding
PROC Star

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1396 views
  • 2 likes
  • 2 in conversation