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

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

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