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

I am analyzing the Breast Cancer Wisconsin (Diagnostic) Data Set, in order to run the logistic regression I have to replace the value of the Diagnosis variable M&B with 0&1.

 

I have tried the below code and some has error occurred:

proc format;
invalue infmt 'B' = 1
              'M' = 0;
run;

data BreastCancer_1;
   set Learn.Oirginal (rename = (cancer_diagnosis=diagnosis));
   cancer_diagnosis = input(diagnosis,infmt.);
   drop diagnosis;  
run;

Error:

 78         data BreastCancer_1;
 79            set Learn.Oirginal (rename = (cancer_diagnosis=diagnosis));
 ERROR: Variable cancer_diagnosis is not on file LEARN.OIRGINAL.
 ERROR: Invalid DROP, KEEP, or RENAME option on file LEARN.OIRGINAL.
 80            cancer_diagnosis = input(diagnosis,infmt.);
 81            drop diagnosis;
 82         run;

Old Dataset - Learn.Oirginal

New Dataset - BreastCancer_1

Old Variable - diagnosis

New Variable - cancer_diagnosis

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
japelin
Rhodochrosite | Level 12

try this code.

data BreastCancer_1;
   set Learn.Oirginal;
   cancer_diagnosis = input(diagnosis,infmt.);
   drop diagnosis;  
run;

View solution in original post

3 REPLIES 3
KachiM
Rhodochrosite | Level 12

Rename = (old1=new1)

In your case, do not use RENAME.

Simply use:

set Learn.Oirginal;
japelin
Rhodochrosite | Level 12

try this code.

data BreastCancer_1;
   set Learn.Oirginal;
   cancer_diagnosis = input(diagnosis,infmt.);
   drop diagnosis;  
run;
VishnuSoman
Calcite | Level 5
Thank you so much, the code has worked.

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 774 views
  • 0 likes
  • 3 in conversation