<?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 Copying selected cells from one column and pasting them into selected cells in another column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/532089#M75512</link>
    <description>&lt;P&gt;Hello, I am a JSL beginner. I need to learn how to move a block of cells in one column to a different location in a different, newly created column.&amp;nbsp; In this case, on top of this new column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Specifically, I need to select a set of cells in column THK marked as PRE in a separate PRE/POST column, and paste them on top of a new column marked THK PRE. It is somewhat similar to the Split Column function, but I do not want to use the Split Column function as I find that, due to some glitch, the data sometimes appears scrambled in the newly created column if the data in some cells of the THK column is missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From some examples on the forums, I put together the code below, but it does not paste any values in the newly created THK PRE column.&amp;nbsp; Please help!&amp;nbsp; Many thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what I need:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Starting data table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THK&amp;nbsp; &amp;nbsp; &amp;nbsp;I&amp;nbsp; &amp;nbsp; PRE/POST&amp;nbsp;&lt;/P&gt;&lt;P&gt;9.5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; POST&lt;/P&gt;&lt;P&gt;9.8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; POST&lt;/P&gt;&lt;P&gt;10.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; POST&lt;/P&gt;&lt;P&gt;11.0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PRE&lt;/P&gt;&lt;P&gt;11.4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRE&lt;/P&gt;&lt;P&gt;10.9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what I need the data table to look like after this operation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THK&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;PRE/POST&amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp;THK PRE&lt;/P&gt;&lt;P&gt;9.5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; POST&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11.0&lt;/P&gt;&lt;P&gt;9.8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; POST&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11.4&lt;/P&gt;&lt;P&gt;10.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;POST&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10.9&lt;/P&gt;&lt;P&gt;11.0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRE&lt;/P&gt;&lt;P&gt;11.4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRE&lt;/P&gt;&lt;P&gt;10.9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script below does not paste any values in the newly created column, the column remains empty&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Pick the source data table
dt=Open("Data Table");

//Create New THK PRE column
dt &amp;lt;&amp;lt; New Column( "THK PRE", Numeric, "Continuous");
Wait(1);


// Select PRE values from THK column
vals = Column(dt, "THK") &amp;lt;&amp;lt; Get Rows Where(:Name("PRE/POST") == "PRE");

// Put these in the new column THK PRE
Column(dt, "THK PRE") &amp;lt;&amp;lt; Set Values(vals)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help! Many thanks in advance.&amp;nbsp; I use JUMP 16.0.0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:52:52 GMT</pubDate>
    <dc:creator>BladeRunner</dc:creator>
    <dc:date>2023-06-10T23:52:52Z</dc:date>
    <item>
      <title>Copying selected cells from one column and pasting them into selected cells in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/532089#M75512</link>
      <description>&lt;P&gt;Hello, I am a JSL beginner. I need to learn how to move a block of cells in one column to a different location in a different, newly created column.&amp;nbsp; In this case, on top of this new column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Specifically, I need to select a set of cells in column THK marked as PRE in a separate PRE/POST column, and paste them on top of a new column marked THK PRE. It is somewhat similar to the Split Column function, but I do not want to use the Split Column function as I find that, due to some glitch, the data sometimes appears scrambled in the newly created column if the data in some cells of the THK column is missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From some examples on the forums, I put together the code below, but it does not paste any values in the newly created THK PRE column.&amp;nbsp; Please help!&amp;nbsp; Many thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what I need:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Starting data table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THK&amp;nbsp; &amp;nbsp; &amp;nbsp;I&amp;nbsp; &amp;nbsp; PRE/POST&amp;nbsp;&lt;/P&gt;&lt;P&gt;9.5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; POST&lt;/P&gt;&lt;P&gt;9.8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; POST&lt;/P&gt;&lt;P&gt;10.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; POST&lt;/P&gt;&lt;P&gt;11.0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PRE&lt;/P&gt;&lt;P&gt;11.4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRE&lt;/P&gt;&lt;P&gt;10.9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what I need the data table to look like after this operation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THK&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp; &amp;nbsp;PRE/POST&amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp;THK PRE&lt;/P&gt;&lt;P&gt;9.5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; POST&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11.0&lt;/P&gt;&lt;P&gt;9.8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; POST&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11.4&lt;/P&gt;&lt;P&gt;10.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;POST&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10.9&lt;/P&gt;&lt;P&gt;11.0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRE&lt;/P&gt;&lt;P&gt;11.4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRE&lt;/P&gt;&lt;P&gt;10.9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script below does not paste any values in the newly created column, the column remains empty&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Pick the source data table
dt=Open("Data Table");

//Create New THK PRE column
dt &amp;lt;&amp;lt; New Column( "THK PRE", Numeric, "Continuous");
Wait(1);


// Select PRE values from THK column
vals = Column(dt, "THK") &amp;lt;&amp;lt; Get Rows Where(:Name("PRE/POST") == "PRE");

// Put these in the new column THK PRE
Column(dt, "THK PRE") &amp;lt;&amp;lt; Set Values(vals)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help! Many thanks in advance.&amp;nbsp; I use JUMP 16.0.0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:52:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/532089#M75512</guid>
      <dc:creator>BladeRunner</dc:creator>
      <dc:date>2023-06-10T23:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Copying selected cells from one column and pasting them into selected cells in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/532092#M75513</link>
      <description>&lt;P&gt;Here is a rework of your script with some added annotation that handles what you want&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Pick the source data table
//dt=Open("Data Table");
dt = New Table( "Example",
	Add Rows( 6 ),
	New Column( "THK",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [9.5, 9.8, 10.1, 11, 11.4, 10.9] )
	),
	New Column( "PRE/POST",
		Character,
		"Nominal",
		Set Values( {"POST", "POST", "POST", "PRE", "PRE", "PRE"} )
	)
);

//Create New THK PRE column
dt &amp;lt;&amp;lt; New Column( "THK PRE", Numeric, "Continuous" );
Wait( 0 );


// Find the rows PRE values from THK column
// and copy those values from the found rows
// to the vals matrix 
vals = :THK[dt &amp;lt;&amp;lt; get rows Where( :Name( "PRE/POST" ) == "PRE" )];

// Put these in the new column THK PRE
dt:THK PRE &amp;lt;&amp;lt; Set Values( vals );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Aug 2022 19:41:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/532092#M75513</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-08-09T19:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Copying selected cells from one column and pasting them into selected cells in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/532130#M75516</link>
      <description>&lt;P&gt;Hello Txnelson, many thanks for the quick response!&amp;nbsp; Works like a charm!&amp;nbsp; &amp;nbsp;I guess I was pretty close, but couldn't quite figure our the syntax.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 21:11:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/532130#M75516</guid>
      <dc:creator>BladeRunner</dc:creator>
      <dc:date>2022-08-09T21:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Copying selected cells from one column and pasting them into selected cells in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/773343#M95436</link>
      <description>&lt;P&gt;is there a way to paste the selected data into a new column in the same row position? or set the values of a new column based on selection?&amp;nbsp; Something like this?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="steveylin_0-1721140991697.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66225i55A4F7A0BD8C803E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="steveylin_0-1721140991697.png" alt="steveylin_0-1721140991697.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2024 14:44:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/773343#M95436</guid>
      <dc:creator>steveylin</dc:creator>
      <dc:date>2024-07-16T14:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: Copying selected cells from one column and pasting them into selected cells in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/773344#M95437</link>
      <description>&lt;P&gt;Here are a couple of ways to do what you want.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Pick the source data table
//dt=Open("Data Table");
dt = New Table( "Example",
	Add Rows( 6 ),
	New Column( "THK",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [9.5, 9.8, 10.1, 11, 11.4, 10.9] )
	),
	New Column( "PRE/POST",
		Character,
		"Nominal",
		Set Values( {"POST", "POST", "POST", "PRE", "PRE", "PRE"} )
	)
);

//Create New THK PRE column
dt &amp;lt;&amp;lt; New Column( "THK PRE1",
	Numeric,
	"Continuous",
	formula( If( :"PRE/POST"n == "PRE", :THK, . ) )
);

dt &amp;lt;&amp;lt; New Column( "THK PRE2", Numeric, "Continuous" );

For Each Row(
	If( :"PRE/POST"n == "PRE",
		:THK PRE2 = :THK,
		:THK PRE2 = .
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want the THK PRE value to be a 5 as illustrated in your second example, just change the resulting value from :THK to 5&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2024 15:06:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/773344#M95437</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-07-16T15:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Copying selected cells from one column and pasting them into selected cells in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/773635#M95493</link>
      <description>&lt;P&gt;Appreciate the response.&amp;nbsp; I was hoping there was a 'paste' script function that I was not aware of.&amp;nbsp; Looks like I will have to loop through each row as you suggested if the column already contains other values.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2024 14:55:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/773635#M95493</guid>
      <dc:creator>steveylin</dc:creator>
      <dc:date>2024-07-17T14:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Copying selected cells from one column and pasting them into selected cells in another column</title>
      <link>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/773723#M95503</link>
      <description>&lt;P&gt;A bit closer to copy/paste: you can get and batch write all values at once:&lt;BR /&gt;&lt;LI-MESSAGE title="Data table subscripting" uid="21013" url="https://community.jmp.com/t5/Uncharted/Data-table-subscripting/m-p/21013#U21013" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&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 = New Table( "Example",
	Add Rows( 100 ),
	New Column( "input",
		Set each Value( random uniform () )
	),
	New Column( "variant",
		Character,
		set each value({"A","B"}[random integer(1,2)])
	)
);

dt &amp;lt;&amp;lt; New Column( "out");
rows= Where(:variant == "A");
vals = dt[rows,"input"];
dt[rows,"out"]=vals;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is similar to&amp;nbsp;&lt;/P&gt;&lt;PRE class="language-jsl"&gt;&lt;CODE&gt;dt:THK PRE &amp;lt;&amp;lt; Set Values( vals );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The difference: via data table indexing you can precisely specify into which rows to write.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Set values&lt;/FONT&gt; starts at row 1 and fills as many rows as there are values in the array.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2024 20:12:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copying-selected-cells-from-one-column-and-pasting-them-into/m-p/773723#M95503</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-07-17T20:12:01Z</dc:date>
    </item>
  </channel>
</rss>

