<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to rename columns using a second data table in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-rename-columns-using-a-second-data-table/m-p/55211#M31215</link>
    <description>&lt;P&gt;Wow! this worked in one go! Thank you!!!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Apr 2018 13:44:08 GMT</pubDate>
    <dc:creator>Aziza</dc:creator>
    <dc:date>2018-04-18T13:44:08Z</dc:date>
    <item>
      <title>How to rename columns using a second data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-rename-columns-using-a-second-data-table/m-p/41065#M23951</link>
      <description>&lt;P&gt;I work with chemical manufacturing process data (think temperature, pressure, flow, composition, etc.) that is retrieved from a process historian. Each variable has both an equipment (tag) name like:&amp;nbsp;LP1LCA0311 and a descriptor (glossary) like: F-301 Level. When automatically exported from Excel to JMP, the glossary is used as column name. The glossary is created by humans, and thus are not usually consistent. Often, it makes sense to use an alias instead of the glossary: functionally, F-301 is the Low Pressure Dust Collector; alias = LVL.LP.DC.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We are building dashboards to monitor our processes. Here is an example:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;six reactors with 31 measurement columns + timestamp&lt;/LI&gt;
&lt;LI&gt;need to rename the columns from glossary to standard alias format like: RX#.LVL; RX#.F.Feed; etc.&lt;/LI&gt;
&lt;LI&gt;standard format will allow for easy stacking: can create a column named Reactor which uses the LEFT() or WORD() functions; rename the Data column using RIGHT() function.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I would like to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use a second data table (DT2) to rename the columns in the first data table (DT1)&lt;/P&gt;
&lt;P&gt;DT2 contains 2 columns: Old.Name = DT1 column names; New.Name =manually entered new column names (alias)&lt;/P&gt;
&lt;P&gt;Script should take Old.Name and insert into new column property = "OldName" in DT1&lt;/P&gt;
&lt;P&gt;Script then renames DT1 columns using DT2 New.Name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code snippet below from Jerry Cooper shows how to do the column property step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Script to take units from column name and assign to column property
// received from Jerry Cooper of SAS 03-Mar-2014
// Data table should have column names of form: Name|units
// Script assumes that units are after "|"
// Easy to set up header row in Excel to concatenate name and units

Names Default To Here( 1 );
dt = Current Data Table();
mycols = dt &amp;lt;&amp;lt; Get Column Names( string );
For( i = 1, i &amp;lt;= N Items( mycols ), i++,
If( Contains( mycols[i], "|" ),
myunits = Substr( mycols[i], Contains( mycols[i], "|", -1 ) + 1 );
newname = Substr( mycols[i], 1, Contains( mycols[i], "|", -1 ) - 1 );
Column( i ) &amp;lt;&amp;lt; Set Name( newname );
Column( i ) &amp;lt;&amp;lt; Set Property( "Units", eval(myunits) );
)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="3"&gt;&lt;SPAN&gt;How would I script the steps to rename the columns in DT1&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="3"&gt;&lt;SPAN&gt;Does anyone have a better way to accomplish what I want?&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 18:45:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-rename-columns-using-a-second-data-table/m-p/41065#M23951</guid>
      <dc:creator>markschahl</dc:creator>
      <dc:date>2017-12-05T18:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename columns using a second data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-rename-columns-using-a-second-data-table/m-p/41070#M23955</link>
      <description>&lt;P&gt;Try this and see if it is what you want&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt2 = New Table( "Lookup",
	Add Rows( 1 ),
	New Column( "Old Name", Character, "Nominal", Set Values( {"Sex"} ) ),
	New Column( "New Name", Character, "Nominal", Set Values( {"Gender"} ) )
);

ColList = dt &amp;lt;&amp;lt; get column names( string );
For( i = 1, i &amp;lt;= N Items( ColList ), i++,
	FoundName = dt2 &amp;lt;&amp;lt; get rows where( Uppercase( :OldName ) == Uppercase( ColList[i] ) );
	If( N Rows( FoundName ) &amp;gt; 0,
		Column( dt, ColList[i] ) &amp;lt;&amp;lt; set property( "Old Name", Eval( ColList[i] ) );
		Column( dt, ColList[i] ) &amp;lt;&amp;lt; set name( dt2:New Name[FoundName[1]] );
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Jun 2017 14:40:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-rename-columns-using-a-second-data-table/m-p/41070#M23955</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-06-22T14:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename columns using a second data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-rename-columns-using-a-second-data-table/m-p/41071#M23956</link>
      <description>Jim:&lt;BR /&gt;&lt;BR /&gt;Thanks for the quick reply! This does what I need. I owe you a beer.</description>
      <pubDate>Thu, 22 Jun 2017 15:27:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-rename-columns-using-a-second-data-table/m-p/41071#M23956</guid>
      <dc:creator>markschahl</dc:creator>
      <dc:date>2017-06-22T15:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename columns using a second data table</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-rename-columns-using-a-second-data-table/m-p/55211#M31215</link>
      <description>&lt;P&gt;Wow! this worked in one go! Thank you!!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 13:44:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-rename-columns-using-a-second-data-table/m-p/55211#M31215</guid>
      <dc:creator>Aziza</dc:creator>
      <dc:date>2018-04-18T13:44:08Z</dc:date>
    </item>
  </channel>
</rss>

