<?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 to get column number from column name? (JMP) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-get-column-number-from-column-name-JMP/m-p/105981#M38982</link>
    <description>&lt;P&gt;Thanks for the solution! A little tip to those out there, if the datatable is not active on the line&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;colname = Column( "height" ) &amp;lt;&amp;lt; getname;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then this line will not work. However, if you specify both the datatable and column name:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;colname = dt:height &amp;lt;&amp;lt; getname;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It works perfectly! Just offering some advice so others dont get hung up like I did ;)&lt;/img&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Jan 2019 17:14:37 GMT</pubDate>
    <dc:creator>twillkickers</dc:creator>
    <dc:date>2019-01-14T17:14:37Z</dc:date>
    <item>
      <title>How to get column number from column name? (JMP)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-column-number-from-column-name-JMP/m-p/5987#M5986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This may be a really simple question but after a lot of searching and testing I can't figure it out.&amp;nbsp; How do I get the column number for a given column if all i know is the column name from a column dialog box?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Minimized code:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;dlg = Column Dialog( dlg_firstParam = ColList( "First Parameter"));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;firstParam = dlg["dlg_firstParam"][1];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;i = 5; // this is a test case.&amp;nbsp; Assume i am going to select the fifth column in the dialog above.&amp;nbsp; If this works, I would write a loop for i = 1 to ncol() and test Column Name ( i ) against the first parameter name... but it doesn't work. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;show(column(i)); // returns:&amp;nbsp;&amp;nbsp; Column("Date");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;show(firstParam); // returns:&amp;nbsp;&amp;nbsp; :Date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;show(columnName(i)); //returns:&amp;nbsp;&amp;nbsp; Date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;//Ok, so given the above two lines, i think I should be able to strip out the colon at the beginning of the string in :Date; and compare to Date; as below.&amp;nbsp; Almost looks like it will work...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;a = parse(right(expr(firstParam),length(expr(firstParam))));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;show (a); // Returns:&amp;nbsp; Date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;// Ok, so the colon gets stripped out.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;if(columnName(i)==a,b = 1, columnName(i)!=a, b = 0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;show (b); // returns 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;//////////////////&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code is a test to see if i can loop through and test if column name ( i ) = a function of firstParam. Looks like it should work, but doesn't. Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The preferred method would be to just return the column number directly.&amp;nbsp; If you can help me with that I would appreciate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(Edit: Just a note to change the last variable in your code from colnumber to some non-JMP keyword. colnumber is reserved. Otherwise works fine.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Nov 2012 17:13:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-column-number-from-column-name-JMP/m-p/5987#M5986</guid>
      <dc:creator>mikedriscoll</dc:creator>
      <dc:date>2012-11-19T17:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to get column number from column name? (JMP)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-column-number-from-column-name-JMP/m-p/5988#M5987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the Loc() function to locate the position of a column name in a list of all column names (ordered as in the data table).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier; color: #942193;"&gt;&lt;SPAN style="color: #000000;"&gt;dt &lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #032ce4;"&gt;Open&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;/SPAN&gt;"$SAMPLE_DATA/Big Class.jmp"&lt;SPAN style="color: #000000;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;collist &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; dt &lt;SPAN style="color: #011993;"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; get column names&lt;STRONG&gt;(&lt;/STRONG&gt; string &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;colname &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="color: #032ce4;"&gt;Column&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;SPAN style="color: #942193;"&gt;"height"&lt;/SPAN&gt; &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;SPAN style="color: #011993;"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; getname&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;SPAN style="color: #032ce4;"&gt;colnumber&lt;/SPAN&gt; &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; &lt;STRONG&gt;(&lt;/STRONG&gt;&lt;SPAN style="color: #032ce4;"&gt;Loc&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; collist&lt;SPAN style="color: #011993;"&gt;,&lt;/SPAN&gt; colname &lt;STRONG&gt;))[&lt;/STRONG&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;]&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Nov 2012 17:41:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-column-number-from-column-name-JMP/m-p/5988#M5987</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2012-11-19T17:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to get column number from column name? (JMP)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-column-number-from-column-name-JMP/m-p/5989#M5988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks MS.&amp;nbsp; Just a note to change the "colnumber" in the last line of your code to some non-JMP keyword. Otherwise it works fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guy I work with suggested a similar solution by obtaining the number directly:&lt;/P&gt;&lt;P&gt;collist &lt;SPAN style="color: #011993;"&gt;=&lt;/SPAN&gt; dt &lt;SPAN style="color: #011993;"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; get column names&lt;STRONG&gt;(&lt;/STRONG&gt; string &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;firstParam_name &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; firstParam &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; get name&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;ColumnNumber &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;contains&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;collist&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; firstParam_name&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Nov 2012 18:14:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-column-number-from-column-name-JMP/m-p/5989#M5988</guid>
      <dc:creator>mikedriscoll</dc:creator>
      <dc:date>2012-11-19T18:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to get column number from column name? (JMP)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-column-number-from-column-name-JMP/m-p/105981#M38982</link>
      <description>&lt;P&gt;Thanks for the solution! A little tip to those out there, if the datatable is not active on the line&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;colname = Column( "height" ) &amp;lt;&amp;lt; getname;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then this line will not work. However, if you specify both the datatable and column name:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;colname = dt:height &amp;lt;&amp;lt; getname;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It works perfectly! Just offering some advice so others dont get hung up like I did ;)&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 17:14:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-column-number-from-column-name-JMP/m-p/105981#M38982</guid>
      <dc:creator>twillkickers</dc:creator>
      <dc:date>2019-01-14T17:14:37Z</dc:date>
    </item>
  </channel>
</rss>

