<?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 JSL question: Update missing column entries from another column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-question-Update-missing-column-entries-from-another-column/m-p/583933#M78997</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to update missing column entries in a data table, with entries from another older column. Using JSL code, and on JMP 14.&lt;/P&gt;&lt;P&gt;Here is the code I am trying to work, but it keeps on throwing error "attempting to assign to an object... L-value access.."&lt;/P&gt;&lt;P&gt;Any help will be appreciated..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=current data table();
Newcols={ "anew", "bnew", "cnew"};
oldcols={ "a", "b", "c"};
		
		
//---Update entries from old cols if new column entry is missing
For( k = 1 , k &amp;lt;= Length( oldcols ), k++,
				
		
		For Each Row(
			temp = column(dt, Newcols[k]); 
			oldc = column(dt, oldcols[k]);
			column (dt,Newcols[k]) = If( Is Missing( as column(dt,Newcols[k]) ) , oldc , temp) ;
			);
	);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:58:44 GMT</pubDate>
    <dc:creator>JazzlikeMag</dc:creator>
    <dc:date>2023-06-10T23:58:44Z</dc:date>
    <item>
      <title>JSL question: Update missing column entries from another column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-question-Update-missing-column-entries-from-another-column/m-p/583933#M78997</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to update missing column entries in a data table, with entries from another older column. Using JSL code, and on JMP 14.&lt;/P&gt;&lt;P&gt;Here is the code I am trying to work, but it keeps on throwing error "attempting to assign to an object... L-value access.."&lt;/P&gt;&lt;P&gt;Any help will be appreciated..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=current data table();
Newcols={ "anew", "bnew", "cnew"};
oldcols={ "a", "b", "c"};
		
		
//---Update entries from old cols if new column entry is missing
For( k = 1 , k &amp;lt;= Length( oldcols ), k++,
				
		
		For Each Row(
			temp = column(dt, Newcols[k]); 
			oldc = column(dt, oldcols[k]);
			column (dt,Newcols[k]) = If( Is Missing( as column(dt,Newcols[k]) ) , oldc , temp) ;
			);
	);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:58:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-question-Update-missing-column-entries-from-another-column/m-p/583933#M78997</guid>
      <dc:creator>JazzlikeMag</dc:creator>
      <dc:date>2023-06-10T23:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: JSL question: Update missing column entries from another column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-question-Update-missing-column-entries-from-another-column/m-p/583949#M78998</link>
      <description>&lt;P&gt;One option would be to use &amp;lt;&amp;lt; Set Each Value()&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(4),
	New Column("a", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, 4])),
	New Column("b", Numeric, "Continuous", Format("Best", 12), Set Values([5, 6, 7, 8])),
	New Column("a2", Numeric, "Continuous", Format("Best", 12), Set Values([11, ., 33, 44])),
	New Column("b2", Numeric, "Continuous", Format("Best", 12), Set Values([., ., 77, .]))
);

wait(2); // demo purposes

new_cols = {"a2", "b2"};
old_cols = {"a", "b"};

For(i = 1, i &amp;lt;= N Items(old_cols), i++,
	Column(dt, new_cols[i]) &amp;lt;&amp;lt; Set Each Value(
		If(Is Missing(AsColumn(Column(dt, new_cols[i]))),
			AsColumn(Column(dt, old_cols[i]))
		,
			AsColumn(Column(dt, new_cols[i]))
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think you have to provide Column with [] or [Row()] if you want to add values like you suggested&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
For(k = 1, k &amp;lt;= Length(old_cols), k++,
	For Each Row(
		new_col_val = Column(dt, new_cols[k])[];
		old_col_val = Column(dt, old_cols[k])[];
		Column(dt, new_cols[k])[] = If(Is Missing(new_col_val), old_col_val, new_col_val)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or use As Column&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For(k = 1, k &amp;lt;= Length(old_cols), k++,
	For Each Row(
		new_col_val = AsColumn(dt, new_cols[k]);
		old_col_val = AsColumn(dt, old_cols[k]);
		AsColumn(dt, new_cols[k])[] = If(Is Missing(new_col_val), old_col_val, new_col_val)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Dec 2022 18:41:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-question-Update-missing-column-entries-from-another-column/m-p/583949#M78998</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-12-20T18:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: JSL question: Update missing column entries from another column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-question-Update-missing-column-entries-from-another-column/m-p/583961#M79000</link>
      <description>&lt;P&gt;Many Thanks, this worked !&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 18:49:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-question-Update-missing-column-entries-from-another-column/m-p/583961#M79000</guid>
      <dc:creator>JazzlikeMag</dc:creator>
      <dc:date>2022-12-20T18:49:47Z</dc:date>
    </item>
  </channel>
</rss>

