BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5

data male female;
set sashelp.class ;
if sex='M' then output male;
else if sex='F' output female ;
run;

proc datasets lib=work memtype=data;
change female=male ;
run;

 

I have rename the dataset names like already we have two datasets male and female.
now i have to rename male dataset as female and female dataset as male 
how to do in proc datasets procedure ?

2 REPLIES 2
Patrick
Opal | Level 21
data male female;
  set sashelp.class;
  if sex='M' then output male;
  else if sex='F' then output female;
run;

proc datasets lib=work memtype=data nolist nowarn;
  delete _male _female;
  run;
  change female=_male male=_female;
  run;
  change _male=male _female=female;
  run;
quit;
Kurt_Bremser
Super User

This is the classic "exchange two objects" problem in computing. You always need a third temporary object to hold one of the values, you can't move the data (or names, in your case) concurrently.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 576 views
  • 2 likes
  • 3 in conversation