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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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