<?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: substitute() for each row() for each column erroring out of bounds in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/substitute-for-each-row-for-each-column-erroring-out-of-bounds/m-p/466424#M71020</link>
    <description>&lt;P&gt;The below slight modification of your code appears to work OK&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
file = Current Data Table();
allCols = file &amp;lt;&amp;lt; get column names( string );
file &amp;lt;&amp;lt; group columns( "col group", allCols );
myCols = file &amp;lt;&amp;lt; get column group( "col group" );
For( cols = 1, cols &amp;lt;= N Items( myCols ), cols++,
	file &amp;lt;&amp;lt; begin data update;
	For Each Row(
		file,
		As Column( file, myCols[cols] ) = Substitute( As Column( file, myCols[cols] ),
			"X", "0"
		)
	);
	file &amp;lt;&amp;lt; end data update;
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 02 Mar 2022 21:57:23 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2022-03-02T21:57:23Z</dc:date>
    <item>
      <title>substitute() for each row() for each column erroring out of bounds</title>
      <link>https://community.jmp.com/t5/Discussions/substitute-for-each-row-for-each-column-erroring-out-of-bounds/m-p/466394#M71013</link>
      <description>&lt;P&gt;I need to search and replace strings across an entire data table. I referenced &lt;A href="https://community.jmp.com/t5/Discussions/How-to-perform-quot-find-amp-replace-quot-in-specific-a-column/td-p/405662" target="_self"&gt;this solution&lt;/A&gt;, hoping for something elegant, but it's complaining about row 11 in my 10-row table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code running on JMP Pro 16.1&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;allCols = file &amp;lt;&amp;lt; get column names(string);
file &amp;lt;&amp;lt; group columns("col group", myCols);
myCols = file &amp;lt;&amp;lt; get column group("col group");
for(cols = 1, cols &amp;lt;= n items(myCols), cols++,
	file &amp;lt;&amp;lt; begin data update;
	for each row(file,
		file:myCols[cols] = substitute(file:myCols[cols],
			"X", "0"
		)
	);
	file &amp;lt;&amp;lt; end data update;
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;PRE&gt;Cannot set value for the column 'dot' because the row number (11) is not valid. &lt;BR /&gt;at row 1 in access or evaluation of 'Assign' , file:myCols[cols] =  /*###*/Substitute( file:myCols[cols], "X", "0" ) /*###*/&lt;/PRE&gt;&lt;P&gt;Forgot to add a sample column:&lt;/P&gt;&lt;PRE&gt;64.0
47.0
2.0
106.0
174.0
12.0
X
2.0
X
14.0&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:12:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/substitute-for-each-row-for-each-column-erroring-out-of-bounds/m-p/466394#M71013</guid>
      <dc:creator>tsandidge</dc:creator>
      <dc:date>2023-06-09T18:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: substitute() for each row() for each column erroring out of bounds</title>
      <link>https://community.jmp.com/t5/Discussions/substitute-for-each-row-for-each-column-erroring-out-of-bounds/m-p/466424#M71020</link>
      <description>&lt;P&gt;The below slight modification of your code appears to work OK&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
file = Current Data Table();
allCols = file &amp;lt;&amp;lt; get column names( string );
file &amp;lt;&amp;lt; group columns( "col group", allCols );
myCols = file &amp;lt;&amp;lt; get column group( "col group" );
For( cols = 1, cols &amp;lt;= N Items( myCols ), cols++,
	file &amp;lt;&amp;lt; begin data update;
	For Each Row(
		file,
		As Column( file, myCols[cols] ) = Substitute( As Column( file, myCols[cols] ),
			"X", "0"
		)
	);
	file &amp;lt;&amp;lt; end data update;
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Mar 2022 21:57:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/substitute-for-each-row-for-each-column-erroring-out-of-bounds/m-p/466424#M71020</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-03-02T21:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: substitute() for each row() for each column erroring out of bounds</title>
      <link>https://community.jmp.com/t5/Discussions/substitute-for-each-row-for-each-column-erroring-out-of-bounds/m-p/466699#M71050</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;, the As Column() did the trick, thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 16:43:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/substitute-for-each-row-for-each-column-erroring-out-of-bounds/m-p/466699#M71050</guid>
      <dc:creator>tsandidge</dc:creator>
      <dc:date>2022-03-03T16:43:44Z</dc:date>
    </item>
  </channel>
</rss>

