<?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 recode multiple columns name with regex in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/recode-multiple-columns-name-with-regex/m-p/487794#M73130</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;I am trying to apply a regex replacement to a Recode Column function in JSL so that the script will go over all columns and apply the regex to all of them, if applicable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code I've been testing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Current Data Table();

//Create list of columns to be recoded 
ColN = dt &amp;lt;&amp;lt; Get Column Names();

// Iterate over the list of columns and recode each one
For Each({listitem}, ColN,
	dt &amp;lt;&amp;lt; Recode Column(
		As Column(listitem),
		{Regex(_rcNow, "erm", "testtest", GLOBALREPLACE)},
		Target Column(Column(listitem))
	);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am getting this error:&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P class=""&gt;Name Unresolved: LocalTime in access or evaluation of 'LocalTime' , LocalTime/*###*/&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P class=""&gt;LocalTime is the first column&amp;nbsp; out of 13 columns in my dataset.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;I would appreciate any help!&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 16:59:25 GMT</pubDate>
    <dc:creator>Lavik17</dc:creator>
    <dc:date>2023-06-09T16:59:25Z</dc:date>
    <item>
      <title>recode multiple columns name with regex</title>
      <link>https://community.jmp.com/t5/Discussions/recode-multiple-columns-name-with-regex/m-p/487794#M73130</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;I am trying to apply a regex replacement to a Recode Column function in JSL so that the script will go over all columns and apply the regex to all of them, if applicable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code I've been testing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Current Data Table();

//Create list of columns to be recoded 
ColN = dt &amp;lt;&amp;lt; Get Column Names();

// Iterate over the list of columns and recode each one
For Each({listitem}, ColN,
	dt &amp;lt;&amp;lt; Recode Column(
		As Column(listitem),
		{Regex(_rcNow, "erm", "testtest", GLOBALREPLACE)},
		Target Column(Column(listitem))
	);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am getting this error:&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P class=""&gt;Name Unresolved: LocalTime in access or evaluation of 'LocalTime' , LocalTime/*###*/&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P class=""&gt;LocalTime is the first column&amp;nbsp; out of 13 columns in my dataset.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;I would appreciate any help!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:59:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/recode-multiple-columns-name-with-regex/m-p/487794#M73130</guid>
      <dc:creator>Lavik17</dc:creator>
      <dc:date>2023-06-09T16:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: recode multiple columns name with regex</title>
      <link>https://community.jmp.com/t5/Discussions/recode-multiple-columns-name-with-regex/m-p/487813#M73131</link>
      <description>&lt;P&gt;I just realized that I used Recode Column and not a function that will rename the column name...&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a dedicated function to recoding a column name? is there another way to accomplish it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 22:35:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/recode-multiple-columns-name-with-regex/m-p/487813#M73131</guid>
      <dc:creator>Lavik17</dc:creator>
      <dc:date>2022-05-17T22:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: recode multiple columns name with regex</title>
      <link>https://community.jmp.com/t5/Discussions/recode-multiple-columns-name-with-regex/m-p/487841#M73135</link>
      <description>&lt;P&gt;A list when specified will not execute any elements within the list.&amp;nbsp; Therefore, the coder needs to force the list to be fully expanded before it is passed to JMP.&amp;nbsp; Below is one way of handling the issue&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Current Data Table();

//Create list of columns to be recoded 
ColN = dt &amp;lt;&amp;lt; Get Column Names(string);

// Iterate over the list of columns and recode each one
For Each( {listitem}, ColN,show(listitem);
	Eval(
		Substitute(
				Expr(
					dt &amp;lt;&amp;lt; Recode Column(
						As Column( listitem ),
						{Regex( __rcNow__, "erm", "testtest", GLOBALREPLACE )},
						Target Column( Column( listitem ) )
					)
				),
			Expr( __rcNow__ ), listitem
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2022 02:59:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/recode-multiple-columns-name-with-regex/m-p/487841#M73135</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-05-18T02:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: recode multiple columns name with regex</title>
      <link>https://community.jmp.com/t5/Discussions/recode-multiple-columns-name-with-regex/m-p/487847#M73138</link>
      <description>&lt;P&gt;There Recode Column Names... which to my knowledge works in similar manner but it won't get recorded to Action Recorder and you cannot get script out of it. There also doesn't seem to be mention of it in Scripting Index.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1652849266550.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/42513iD1564B81D512FB87/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1652849266550.png" alt="jthi_0-1652849266550.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You might have to create loop and use for example Regex() and &amp;lt;&amp;lt; Set Name to columns.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("test",
	new column("erm")
);

wait(1); // for demo

For Each({col_name}, dt &amp;lt;&amp;lt; Get Column Names("String"),
	new_col_name = Regex(col_name, "erm", "testtest", GLOBALREPLACE);
	Column(dt, col_name) &amp;lt;&amp;lt; Set Name(new_col_name);
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 04:56:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/recode-multiple-columns-name-with-regex/m-p/487847#M73138</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-05-18T04:56:46Z</dc:date>
    </item>
  </channel>
</rss>

