DATA Step, Macro, Functions and more

prefix all column names of a dataset

Reply
Frequent Contributor
Posts: 110

prefix all column names of a dataset

[ Edited ]

Let us say I have a dataset with 2 columns: Col1 and Col2. Is it possibly to change all column names so that they start with X (Col1 => XCol1, Col2 => XCol2) without having to do this manually?

Contributor
Posts: 21

Re: append all column names of a dataset

[ Edited ]
Posted in reply to csetzkorn

I hope this will help u 

http://support.sas.com/kb/48/674.html

Super User
Posts: 19,877

Re: append all column names of a dataset

Posted in reply to csetzkorn

Are your original variables sequentially named as in your example?

If yes, then you can use a rename

 

RENAME Col1-Col2 = Xcol1 - Xcol2;

Otherwise, use the SASHELP.VCOLUMN table to generate the rename statement dynamically.

 

Here's an example from a few days ago:

https://communities.sas.com/t5/Base-SAS-Programming/rename-variables/m-p/333964

Ask a Question
Discussion stats
  • 2 replies
  • 187 views
  • 2 likes
  • 3 in conversation