<?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: Copy selection and paste into new columns in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Copy-selection-and-paste-into-new-columns/m-p/621419#M82050</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;If you want to copy and paste value based on row selection, you can write code like the following.&lt;/P&gt;
&lt;P&gt;I hope it helps.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; Select Where( :Products == unique_values[k] );
r = dt &amp;lt;&amp;lt; Get Selected Rows();
val = As Column( colNames[i] )[r];
For( h = 1, h &amp;lt;= N Row( val ), h++,
	As Column( colNames2[i] )[r[h]] = val[h]
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 10 Apr 2023 07:36:53 GMT</pubDate>
    <dc:creator>yuichi_katsumur</dc:creator>
    <dc:date>2023-04-10T07:36:53Z</dc:date>
    <item>
      <title>Copy selection and paste into new columns</title>
      <link>https://community.jmp.com/t5/Discussions/Copy-selection-and-paste-into-new-columns/m-p/618771#M81812</link>
      <description>&lt;P&gt;Hello, I have a set of columns with data for multiple products by rows. I need to split up this data by creating new identical columns with product name suffix and copy over only the matching product data from previous columns. I just need help to copy over appropriate data. I was trying to do this with selections and copy paste, but I am not sure how to. Region of interest is starting from dt &amp;lt;&amp;lt; Select Where onwards.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
colNames = dt &amp;lt;&amp;lt; Get Column Names(String);
//Select set of columns to split
for (i = nitems(colNames), i &amp;gt; 0, i--,
     if (!contains(colNames[i], "SPC"),
           remove from(colNames, i);
     );
);

//Add new columns with product name suffix and copy/paste properties
Summarize(unique_values=by(:Products));
colNames2=colNames;
for (k = nitems(unique_values), k &amp;gt; 0, k--,
	for (i = nitems(colNames), i &amp;gt; 0, i--,
		colNames2[i] = colNames[i] || " " || unique_values[k];
		dt &amp;lt;&amp;lt; New Column( colNames2[i] );
	); 
	for( j = 1, j &amp;lt;= nitems(colNames), j++,
		colProps = Column( dt, colNames[j] ) &amp;lt;&amp;lt; Get Column Properties;
		Column( dt, colNames2[j] ) &amp;lt;&amp;lt; Add Column Properties( colProps );
	);
&lt;U&gt;&lt;STRONG&gt;	dt &amp;lt;&amp;lt; Select Where( :Products == unique_values[k] );
		dt &amp;lt;&amp;lt; selectColumns(colNames);
		dt &amp;lt;&amp;lt; Copy;
		dt &amp;lt;&amp;lt; selectColumns(colNames2);
		dt &amp;lt;&amp;lt; Paste;&lt;/STRONG&gt;&lt;/U&gt;
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:07:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copy-selection-and-paste-into-new-columns/m-p/618771#M81812</guid>
      <dc:creator>ChebyshevOcelot</dc:creator>
      <dc:date>2023-06-09T16:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: Copy selection and paste into new columns</title>
      <link>https://community.jmp.com/t5/Discussions/Copy-selection-and-paste-into-new-columns/m-p/621419#M82050</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;If you want to copy and paste value based on row selection, you can write code like the following.&lt;/P&gt;
&lt;P&gt;I hope it helps.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; Select Where( :Products == unique_values[k] );
r = dt &amp;lt;&amp;lt; Get Selected Rows();
val = As Column( colNames[i] )[r];
For( h = 1, h &amp;lt;= N Row( val ), h++,
	As Column( colNames2[i] )[r[h]] = val[h]
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2023 07:36:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copy-selection-and-paste-into-new-columns/m-p/621419#M82050</guid>
      <dc:creator>yuichi_katsumur</dc:creator>
      <dc:date>2023-04-10T07:36:53Z</dc:date>
    </item>
  </channel>
</rss>

