Help using Base SAS procedures

rename colum

Reply
Occasional Contributor
Posts: 12

rename colum

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;
Regular Contributor
Posts: 165

Re: rename colum

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.
Occasional Contributor
Posts: 12

Re: rename colum

thanks, that was it. I'm just learning sas.
Super Contributor
Super Contributor
Posts: 365

Re: rename colum

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
Ask a Question
Discussion stats
  • 3 replies
  • 164 views
  • 0 likes
  • 3 in conversation