cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
masum111bd
Level II

Renaming columns with loop

Hi,

I am trying to rename few columns. Basically I want to append "OFL" character at the end of original column name.

I trried this script but no success.

dt = Current Data Table();
For( i = 25, i <= N Cols( dt ), i++,
newname = :Column Name( dt, i )||"OFL";
Column( dt, i ) << Set Name( newname );
);
1 ACCEPTED SOLUTION

Accepted Solutions
David_Burnham
Super User (Alumni)

Re: Renaming columns with loop

dt = Current Data Table();
For( i = 25, i <= N Cols( dt ), i++,
	cName = Column(dt,i) << Get Name;
	newname = cName|| "OFL";
	Column( dt, i ) << Set Name( newname );
);
-Dave

View solution in original post

3 REPLIES 3
David_Burnham
Super User (Alumni)

Re: Renaming columns with loop

dt = Current Data Table();
For( i = 25, i <= N Cols( dt ), i++,
	cName = Column(dt,i) << Get Name;
	newname = cName|| "OFL";
	Column( dt, i ) << Set Name( newname );
);
-Dave
masum111bd
Level II

Re: Renaming columns with loop

Thanks David. It works fine.

markschahl
Level V

Re: Renaming columns with loop

Just in case you want to do this with a second data table, here's how:

 

How-to-rename-columns-using-a-second-data-table

 

I use this a lot now since #TXNelson showed me how to do this!