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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 871 views
  • 0 likes
  • 3 in conversation