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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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