#I'm Trying to fill up missing values for variable age with adding new column call age_ which will filled with the condition then i ll drop the column age and rename age_ to age however i got the warning above in subject and missing values still missing
Data DATA bank_Filling_All_Missing ;
SET bank_filling_Income;
Age_ = .;
if(Age<0) and (res = 'U') then Age_ = 47.9;
if(Age >1) and (res = 'U') then Age_ = Age;
if(Age<0) and (res = 'R') then Age_ = 48.16;
if(Age>1) and (res = 'R') then Age_ = Age;
if(Age<0) and (res = 'S') then Age_ = 47.7;
if(Age>1) and (res = 'S') then Age_ = Age;
drop Age_;
rename Age_ =Age;
RUN ;
what are the issues
Hi @MAJEED
It seems you have two issues:
Data /*DATA*/ bank_Filling_All_Missing ;
SET bank_filling_Income;
Age_ = .;
if(Age<0) and (res = 'U') then Age_ = 47.9;
if(Age >1) and (res = 'U') then Age_ = Age;
if(Age<0) and (res = 'R') then Age_ = 48.16;
if(Age>1) and (res = 'R') then Age_ = Age;
if(Age<0) and (res = 'S') then Age_ = 47.7;
if(Age>1) and (res = 'S') then Age_ = Age;
drop Age/*_*/;
rename Age_ =Age;
RUN ;
what are the issues
HI @MAJEED
Look at the portion in the code I have put in comments ->
/*DATA*/
/*_*/ -> Age instead of Age_
@MAJEED wrote:
what are the issues
When you DROP a variable it is no longer available to RENAME.
Note that statements like DROP are not executable. That means the order of their of appearance in a data step doesn't matter. The variable is Dropped. Period.
Which is why you get the same warning with this code:
152 data junk; 153 Set sashelp.class; 154 rename age=newage; 155 drop age; 156 run; WARNING: The variable age in the DROP, KEEP, or RENAME list has never been referenced. NOTE: There were 19 observations read from the data set SASHELP.CLASS.
plz try
drop Age;
rename Age_ =Age;
instead of
drop Age_;
rename Age_ =Age;
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!
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.