BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
serakuru1989
Calcite | Level 5

How do I covert N and O to 1 and 0 to do correlation and regression analysis? Please help me with this.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Follow the documentation example then: https://documentation.sas.com/?docsetId=statug&docsetTarget=statug_logistic_examples02.htm&docsetVer...

I would recommend running the documentation example first, make sure you understand it and then try it with your own data. The example doesn't do one thing I would recommend, set the class variables to have the REF parameterization.

class <list of categorical variables> / param=ref;

View solution in original post

3 REPLIES 3
Reeza
Super User

What PROC are you using for regression?

 

If it's PROC LOGISTIC or GLM (and several others) you can use a CLASS statement to specify this is a categorical variable. You'll also want to specify the reference level but you don't need to convert them to 0/1 manually. Otherwise you can use IF/THEN statements to make a new variable. 

 


@serakuru1989 wrote:

How do I covert N and O to 1 and 0 to do correlation and regression analysis? Please help me with this.


 

if varName = "N" then varName_Cat = 0;
else if varName = "O" then varName_Cat = 1;
serakuru1989
Calcite | Level 5

I am very much new in this. Using PROC Logistic.

How do I write a CLASS statement to specify this is a categorical variable?

Reeza
Super User
Follow the documentation example then: https://documentation.sas.com/?docsetId=statug&docsetTarget=statug_logistic_examples02.htm&docsetVer...

I would recommend running the documentation example first, make sure you understand it and then try it with your own data. The example doesn't do one thing I would recommend, set the class variables to have the REF parameterization.

class <list of categorical variables> / param=ref;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 990 views
  • 0 likes
  • 2 in conversation