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 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!

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.

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