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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1125 views
  • 0 likes
  • 3 in conversation