<?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: How can I easily retrieve the column &amp;quot;position&amp;quot; in a large table? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-can-I-easily-retrieve-the-column-quot-position-quot-in-a/m-p/52541#M29747</link>
    <description>&lt;P&gt;I'd forgotten about the "string" argument!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 03 Mar 2018 04:26:52 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2018-03-03T04:26:52Z</dc:date>
    <item>
      <title>How can I easily retrieve the column "position" in a large table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-I-easily-retrieve-the-column-quot-position-quot-in-a/m-p/52529#M29741</link>
      <description>&lt;P&gt;Hello JMP Community,&lt;/P&gt;&lt;P&gt;While writing quick and simple scripts with For loops, I usually enter the starting and ending columns manually (i.e. For i=start, i &amp;lt;=end, i++) to&amp;nbsp;allow for the analysis of different ranges of variables.&lt;/P&gt;&lt;P&gt;Is there a simple way to retrieve the position of a given column to use as either starting or ending column? I use the rather awkward method of selecting all columns&amp;nbsp;up to the&amp;nbsp;desired&amp;nbsp;column but it seems highly inefficient. Another method I have used is to create a new table where the column names are stacked in rows and use the row numbers as positions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I assume that there is a simpler method that has escaped me so far.&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Mar 2018 01:20:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-I-easily-retrieve-the-column-quot-position-quot-in-a/m-p/52529#M29741</guid>
      <dc:creator>sornasst</dc:creator>
      <dc:date>2018-03-03T01:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I easily retrieve the column "position" in a large table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-I-easily-retrieve-the-column-quot-position-quot-in-a/m-p/52539#M29745</link>
      <description>&lt;P&gt;What I use is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;position=Loc(dt&amp;lt;&amp;lt;get column names("string"),"theDesiredColumn")[1];&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Mar 2018 04:24:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-I-easily-retrieve-the-column-quot-position-quot-in-a/m-p/52539#M29745</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-03-03T04:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I easily retrieve the column "position" in a large table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-I-easily-retrieve-the-column-quot-position-quot-in-a/m-p/52540#M29746</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=open("$sample_data/big class.jmp");
lookup=associativearray((dt&amp;lt;&amp;lt;getcolumnreference)&amp;lt;&amp;lt;getname,1::ncols(dt));
show(lookup["age"],lookup["height"]);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;lookup["age"] = 2;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;lookup["height"] = 4;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The associative array must be rebuilt if the columns are moved/deleted/added in the table. dt&amp;lt;&amp;lt;GetColumnReference returns a list of columns; sending that list the &amp;lt;&amp;lt;GetName message produces a list of the string names of the columns that can be used as the keys to the associative array. The matrix 1::ncols(dt) makes the values for the associative array. The lookups are then done with the string name of the column.&lt;/P&gt;
&lt;P&gt;There is also a dt&amp;lt;&amp;lt;GetColumnNames message that returns the names (not strings) of the columns. Those names are harder to work with than the list of columns from dt&amp;lt;&amp;lt;GetColumnReference.&amp;nbsp; The column&amp;lt;&amp;lt;GetName message returns&amp;nbsp;a string (in spite of its name).&amp;nbsp;In the example, &amp;lt;&amp;lt;GetName is sent to a { list of columns } which causes the message to be sent to each item in the list and a new list is built from the results.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Mar 2018 04:24:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-I-easily-retrieve-the-column-quot-position-quot-in-a/m-p/52540#M29746</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2018-03-03T04:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I easily retrieve the column "position" in a large table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-I-easily-retrieve-the-column-quot-position-quot-in-a/m-p/52541#M29747</link>
      <description>&lt;P&gt;I'd forgotten about the "string" argument!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Mar 2018 04:26:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-I-easily-retrieve-the-column-quot-position-quot-in-a/m-p/52541#M29747</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2018-03-03T04:26:52Z</dc:date>
    </item>
  </channel>
</rss>

