<?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: Table Update: How to update only selected columns? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Table-Update-How-to-update-only-selected-columns/m-p/605773#M80807</link>
    <description>&lt;P&gt;&amp;nbsp;HI, this will probably do what you are looking for&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 );

// opens Table
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );

//generate update Table
dt2 = dt1 &amp;lt;&amp;lt; Clear Select &amp;lt;&amp;lt; Select Rows( Index( 1, 8 ) ) &amp;lt;&amp;lt; Subset( Selected Rows( 1 ), Selected columns only( 0 ) );

// delete contend
for(k=4,k&amp;lt;=ncols(dt1),k++,column(dt1,k)[(1 :: 8)]=.);

//select columns
dt1 &amp;lt;&amp;lt; Clear select;
wait(0.1);
dt1 &amp;lt;&amp;lt; Select Rows ( (3::5) );
wait(0.1);



// ### scrpit only with selected rows

// get selected rows
s_rows = dt1 &amp;lt;&amp;lt; Get Selected Rows();

// create a new column with selected rows as 1
n_c1 = dt1 &amp;lt;&amp;lt; new column();
n_c1[s_rows]=1;

// create a new column on the update table
n_c2 = dt2 &amp;lt;&amp;lt;  New Column("temp",Numeric,"Continuous",&amp;lt;&amp;lt;Set Initial Data( 1 ));

// update only where the 1 is present (selected rows only)
dt1 &amp;lt;&amp;lt; Update(
	With( dt2 ),
	Match Columns( :name = :name, n_c1 = n_c2 ),
);

// delete the columns
dt1 &amp;lt;&amp;lt; Delete Columns(n_c1);&lt;BR /&gt;dt2 &amp;lt;&amp;lt; Delete Columns(n_c2);&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Feb 2023 14:00:35 GMT</pubDate>
    <dc:creator>Mauro_Gerber</dc:creator>
    <dc:date>2023-02-27T14:00:35Z</dc:date>
    <item>
      <title>Table Update: How to update only selected columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Table-Update-How-to-update-only-selected-columns/m-p/605711#M80804</link>
      <description>&lt;P&gt;This should be a quick one:&lt;/P&gt;&lt;P&gt;Table update: How to update only selected columns?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( dt1 ) &amp;lt;&amp;lt; Update(
	With( Data Table( dt10 ) ),
	Match Columns( :SAMPLE = :SamID ),
	Add Columns from Update Table( None ),&lt;BR /&gt;    ### Update Selected Columns (:Type, :Method) ###&lt;BR /&gt;)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It's simple when done manually, but in the script? There's nothing in the scripting guide (only how to avoid adding columns). My various guesses and trials (eg. see inside&amp;nbsp; ###&amp;nbsp; in above script) do not work.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:32:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Table-Update-How-to-update-only-selected-columns/m-p/605711#M80804</guid>
      <dc:creator>Monomorphist</dc:creator>
      <dc:date>2023-06-08T16:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Table Update: How to update only selected columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Table-Update-How-to-update-only-selected-columns/m-p/605720#M80805</link>
      <description>&lt;P&gt;If you have JMP16 you can perform the action once manually and then get the script from enhanced log, most likely what you are looking for is Replace Columns in Main Table()&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table("Big Class") &amp;lt;&amp;lt; Update(
	With(Data Table("Subset of Big Class")),
	Match Columns(:name = :name),
	Replace Columns in Main Table(:age)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1677496860910.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50493i59B6E9F779EDFC98/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1677496860910.png" alt="jthi_0-1677496860910.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 11:23:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Table-Update-How-to-update-only-selected-columns/m-p/605720#M80805</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-02-27T11:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: Table Update: How to update only selected columns?</title>
      <link>https://community.jmp.com/t5/Discussions/Table-Update-How-to-update-only-selected-columns/m-p/605773#M80807</link>
      <description>&lt;P&gt;&amp;nbsp;HI, this will probably do what you are looking for&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 );

// opens Table
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );

//generate update Table
dt2 = dt1 &amp;lt;&amp;lt; Clear Select &amp;lt;&amp;lt; Select Rows( Index( 1, 8 ) ) &amp;lt;&amp;lt; Subset( Selected Rows( 1 ), Selected columns only( 0 ) );

// delete contend
for(k=4,k&amp;lt;=ncols(dt1),k++,column(dt1,k)[(1 :: 8)]=.);

//select columns
dt1 &amp;lt;&amp;lt; Clear select;
wait(0.1);
dt1 &amp;lt;&amp;lt; Select Rows ( (3::5) );
wait(0.1);



// ### scrpit only with selected rows

// get selected rows
s_rows = dt1 &amp;lt;&amp;lt; Get Selected Rows();

// create a new column with selected rows as 1
n_c1 = dt1 &amp;lt;&amp;lt; new column();
n_c1[s_rows]=1;

// create a new column on the update table
n_c2 = dt2 &amp;lt;&amp;lt;  New Column("temp",Numeric,"Continuous",&amp;lt;&amp;lt;Set Initial Data( 1 ));

// update only where the 1 is present (selected rows only)
dt1 &amp;lt;&amp;lt; Update(
	With( dt2 ),
	Match Columns( :name = :name, n_c1 = n_c2 ),
);

// delete the columns
dt1 &amp;lt;&amp;lt; Delete Columns(n_c1);&lt;BR /&gt;dt2 &amp;lt;&amp;lt; Delete Columns(n_c2);&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 14:00:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Table-Update-How-to-update-only-selected-columns/m-p/605773#M80807</guid>
      <dc:creator>Mauro_Gerber</dc:creator>
      <dc:date>2023-02-27T14:00:35Z</dc:date>
    </item>
  </channel>
</rss>

