BookmarkSubscribeRSS Feed
tjonas
Calcite | Level 5
Trying to rename a column titled country, I tried the code below but when it runs the column name is changed but the data is gone.


data births.father (drop=country);
set births.father;
country=dadbirthplacecountry;
run;
3 REPLIES 3
RickM
Fluorite | Level 6
Do you have country and dadbirthplacecountry in the wrong sides of the equals sign? If all you are doing is renaming then proc datasets might be a better choice.
tjonas
Calcite | Level 5
thanks, that was it. I'm just learning sas.
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Tjonas,

Look at your code:

country=dadbirthplacecountry;

copies from dadbirthplacecountry to country. Then

data births.father (drop=country);

deletes country from output dataset. It means that if the input dataset birth.father does not contain dadbirthplacecountry then this column will be empty in the output dataset births.father. It looks like you neet the following:
[pre]
data births.father;
set births.father;
rename country=dadbirthplacecountry;
run;
[/pre]
Sincerely,
SPR

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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