<?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 JSL change part of col name based on values from another table in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-change-part-of-col-name-based-on-values-from-another-table/m-p/559265#M77272</link>
    <description>&lt;P&gt;After running a general query to collect lots of data with general header of bin01, bin02, .... bin16.&amp;nbsp; I want to update column headers based on a different able that has bin information based on recipe.&amp;nbsp; This seems an easy task using a munger command, but errors when placed into a nested loop.&amp;nbsp; Same syntax works in a single loop format, but since there will be a variable number of bin values to replace 1 to 16 possible a loop structure is preferred.&amp;nbsp; I have attached sample data tables and JSL.&amp;nbsp; Any recommendations are appreciated.&amp;nbsp; Working on this issue using JMP16.1&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:55:46 GMT</pubDate>
    <dc:creator>chris_dennis</dc:creator>
    <dc:date>2023-06-10T23:55:46Z</dc:date>
    <item>
      <title>JSL change part of col name based on values from another table</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-change-part-of-col-name-based-on-values-from-another-table/m-p/559265#M77272</link>
      <description>&lt;P&gt;After running a general query to collect lots of data with general header of bin01, bin02, .... bin16.&amp;nbsp; I want to update column headers based on a different able that has bin information based on recipe.&amp;nbsp; This seems an easy task using a munger command, but errors when placed into a nested loop.&amp;nbsp; Same syntax works in a single loop format, but since there will be a variable number of bin values to replace 1 to 16 possible a loop structure is preferred.&amp;nbsp; I have attached sample data tables and JSL.&amp;nbsp; Any recommendations are appreciated.&amp;nbsp; Working on this issue using JMP16.1&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:55:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-change-part-of-col-name-based-on-values-from-another-table/m-p/559265#M77272</guid>
      <dc:creator>chris_dennis</dc:creator>
      <dc:date>2023-06-10T23:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: JSL change part of col name based on values from another table</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-change-part-of-col-name-based-on-values-from-another-table/m-p/559279#M77274</link>
      <description>&lt;P&gt;Here is a rework of your script that works with your sample data tables.&amp;nbsp; The main change is the addition of the Try() function, that keeps the code from stopping when an error within the Set () occures.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;			//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Need to update data table based on bins in recipe, name and get rid of Bin Cols no data was collected, bins greater that number defined by bin size list
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  	Referance: https://community.jmp.com/t5/JMP-Scripts/Find-amp-Replace-for-Column-Names/ta-p/217124
b = Data Table( "BinSizeList" ):Name( "CntBins" ) &amp;lt;&amp;lt; get values;
Show( b );
Show( b[1] );
bnum = Data Table( "BinSizeList" ):Name( "Label" ) &amp;lt;&amp;lt; get values;
Show( bnum );
bsize = Data Table( "BinSizeList" ):Name( "Bin_Label" ) &amp;lt;&amp;lt; get values;
Show( bsize );
			
Data Table( "LPD_Data" ) &amp;lt;&amp;lt; Select Columns( ALL );
cols = Data Table( "LPD_Data" ) &amp;lt;&amp;lt; Get Selected Columns();
Show( cols );

//			Nested loop does not work?  Error on "set name" comand only when nested j loop is included.  Works fine if j for statement is removed and [ j ] replaced with a valid number
			
For( i = 1, i &amp;lt;= N Items( cols ), i++,
	For( j = 1, j &amp;lt;= b[1], j++,
		Try(
			cols[i] &amp;lt;&amp;lt; set name(
				Munger(
					Char( cols[i] ), // &amp;lt;&amp;lt; get name,
					1,
					Eval( Char( bnum[j] ) ),
					Eval( Char( bsize[j] ) )
				)
			)
		)
	)
);
			

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 22 Oct 2022 00:38:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-change-part-of-col-name-based-on-values-from-another-table/m-p/559279#M77274</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-10-22T00:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: JSL change part of col name based on values from another table</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-change-part-of-col-name-based-on-values-from-another-table/m-p/560210#M77371</link>
      <description>&lt;P&gt;Thanks, for your help.&amp;nbsp; I had not seen the TRY command before.&amp;nbsp; Worked great.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 23:21:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-change-part-of-col-name-based-on-values-from-another-table/m-p/560210#M77371</guid>
      <dc:creator>chris_dennis</dc:creator>
      <dc:date>2022-10-25T23:21:25Z</dc:date>
    </item>
  </channel>
</rss>

