<?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 Column difference- JSL syntax in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Column-difference-JSL-syntax/m-p/37633#M22072</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to access the contents of a column by the column reference? Since my column names keep changing with every loop in the script, I can't just simple use the column name to subtract.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dt is my data table and has 30 columns. I want to create a new column with dt[28]- dt[30].&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me with syntax?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really appreciate it. Thank you.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Mar 2017 19:55:30 GMT</pubDate>
    <dc:creator>vishwasanj</dc:creator>
    <dc:date>2017-03-29T19:55:30Z</dc:date>
    <item>
      <title>Column difference- JSL syntax</title>
      <link>https://community.jmp.com/t5/Discussions/Column-difference-JSL-syntax/m-p/37633#M22072</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to access the contents of a column by the column reference? Since my column names keep changing with every loop in the script, I can't just simple use the column name to subtract.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dt is my data table and has 30 columns. I want to create a new column with dt[28]- dt[30].&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me with syntax?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really appreciate it. Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2017 19:55:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Column-difference-JSL-syntax/m-p/37633#M22072</guid>
      <dc:creator>vishwasanj</dc:creator>
      <dc:date>2017-03-29T19:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: Column difference- JSL syntax</title>
      <link>https://community.jmp.com/t5/Discussions/Column-difference-JSL-syntax/m-p/37635#M22074</link>
      <description>&lt;P&gt;There is more than one way to refer to a column:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;:name&lt;/LI&gt;
&lt;LI&gt;Column( "name" )&lt;/LI&gt;
&lt;LI&gt;Column( data table reference, "name" )&lt;/LI&gt;
&lt;LI&gt;Column( index )&lt;/LI&gt;
&lt;LI&gt;Column( data table reference, index )&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I suspect that the last two forms based on the Column() function will be useful in your case.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2017 20:10:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Column-difference-JSL-syntax/m-p/37635#M22074</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2017-03-29T20:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Column difference- JSL syntax</title>
      <link>https://community.jmp.com/t5/Discussions/Column-difference-JSL-syntax/m-p/37637#M22076</link>
      <description>&lt;P&gt;Additionally, if you're running JMP 13, you can subscript into a data table using dt[row, column], and you can use ranges (1::4).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a short example that adds a new column and sets its values to column 3 - columnn 1:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = New Table( "Table Subscripting",
	New Column( "a", Set Values( [1 2 3 4 5] ) ),
	New Column( "b", Set Values( [44 22 77 55 99] ) ),
	New Column( "c", Set Values( [59, 58, 57, 56, 55] ) )
);
dt &amp;lt;&amp;lt; New Column( "new column" );
dt[1::nrow(dt), 4] = dt[1::nrow(dt), 3] - dt[1::nrow(dt), 1];
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Mar 2017 20:42:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Column-difference-JSL-syntax/m-p/37637#M22076</guid>
      <dc:creator>Melanie_J_Drake</dc:creator>
      <dc:date>2017-03-29T20:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Column difference- JSL syntax</title>
      <link>https://community.jmp.com/t5/Discussions/Column-difference-JSL-syntax/m-p/37639#M22078</link>
      <description>Does 4 automatically imply it's the end of the table? Since the data table columns keeps changing , can i use&lt;BR /&gt;dt[1::nrow(dt), endcol+1] = dt[1::nrow(dt), startcol] - dt[1::nrow(dt), endcol];&lt;BR /&gt;&lt;BR /&gt;where endCol = ncols( kdt ); and startcol= 28( This is derived after a particular column)&lt;BR /&gt;&lt;BR /&gt;I am trying to make everything dynamic.&lt;BR /&gt;I don't think this works. What your your thoughts on this Melanie?</description>
      <pubDate>Wed, 29 Mar 2017 22:25:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Column-difference-JSL-syntax/m-p/37639#M22078</guid>
      <dc:creator>vishwasanj</dc:creator>
      <dc:date>2017-03-29T22:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Column difference- JSL syntax</title>
      <link>https://community.jmp.com/t5/Discussions/Column-difference-JSL-syntax/m-p/37640#M22079</link>
      <description>Hi Mark,&lt;BR /&gt;&lt;BR /&gt;Apparently, I cannot use this syntax of&lt;BR /&gt;dt&amp;lt;&amp;lt; New Column( "Delta",&lt;BR /&gt;Numeric,&lt;BR /&gt;Formula( Column(dt,startcol)- Column(dt,endcol) )&lt;BR /&gt;&lt;BR /&gt;);&lt;BR /&gt;&lt;BR /&gt;startcol= 28( which is derived after a particular column)&lt;BR /&gt;and endCol = ncols( dt );&lt;BR /&gt;&lt;BR /&gt;Since my data tables number of columns keeps changing after every loop, I can't use a number. Is there any other way?&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Mar 2017 22:27:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Column-difference-JSL-syntax/m-p/37640#M22079</guid>
      <dc:creator>vishwasanj</dc:creator>
      <dc:date>2017-03-29T22:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Column difference- JSL syntax</title>
      <link>https://community.jmp.com/t5/Discussions/Column-difference-JSL-syntax/m-p/37648#M22084</link>
      <description>&lt;P&gt;This example shows how&amp;nbsp;variables can be used for defining columns dynamically when 1) using the matrix notation for tables in JMP 13 or 2) setting a formula.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = New Table("Table Subscripting",
    New Column("a", Set Values([1 2 3 4 5])),
    New Column("b", Set Values([44 22 77 55 99])),
    New Column("c", Set Values([59, 58, 57, 56, 55]))
);

startCol = 1;
endCol = N Col(dt);

// New column with the diff between endCol and startCol can be filled
// 1) with static values using matrix notation (JMP 13),

dt &amp;lt;&amp;lt; New Column("Delta");
dt[0, endCol + 1] = dt[0, endCol] - dt[0, startCol];

// 2) or by a Column Formula
// (expression must partly be pre-evaluated if variables are used)

F = Eval Expr(Expr(Column(endCol))[] - Expr(Column(startCol))[]);
dt &amp;lt;&amp;lt; New Column("Delta2", Formula(Name Expr(F)));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Mar 2017 09:36:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Column-difference-JSL-syntax/m-p/37648#M22084</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2017-03-30T09:36:31Z</dc:date>
    </item>
  </channel>
</rss>

