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

 

 

#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 ;

1 ACCEPTED SOLUTION
5 REPLIES 5
ed_sas_member
Meteorite | Level 14

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 ;
ed_sas_member
Meteorite | Level 14

HI @MAJEED 

 

Look at the portion in the code I have put in comments ->

/*DATA*/

/*_*/ -> Age instead of Age_

ballardw
Super User

@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.

novinosrin
Tourmaline | Level 20

plz try

 

drop Age;
rename Age_ =Age;

 

instead of

drop Age_;
rename Age_ =Age;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 518 views
  • 0 likes
  • 4 in conversation