<?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: Excel VBA - Subset data by column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Excel-VBA-Subset-data-by-column/m-p/14492#M13522</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi JB,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a full automation reference installed in the Documentation directory where JMP 11 is installed.&amp;nbsp; If you are getting a bad reference, that means either JMP failed to start (App object is empty) or it could not find the Big Class data table and that reference is empty.&amp;nbsp; Please keep in mind that if you are using JMPPro, the directory will be different JMPPRO\11, not JMP\11.&amp;nbsp; The same goes for other JMP products.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This sample is doing a subset, with a Random sample size of 2.&amp;nbsp; Stratify is set, with the age column being used for the stratified sample.&amp;nbsp; Only the selected columns will be output.&amp;nbsp; In this case, name, height and weight are the selected columns.&amp;nbsp; I am attaching a picture of what this would look like if you were to do this interactively.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Brian Corcoran&lt;/P&gt;&lt;P&gt;JMP Development&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Sep 2015 19:32:57 GMT</pubDate>
    <dc:creator>briancorcoran</dc:creator>
    <dc:date>2015-09-28T19:32:57Z</dc:date>
    <item>
      <title>Excel VBA - Subset data by column</title>
      <link>https://community.jmp.com/t5/Discussions/Excel-VBA-Subset-data-by-column/m-p/14491#M13521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I'm looking at a sample program included with JMP 11:&lt;/P&gt;&lt;P&gt;&amp;nbsp; C:\Program Files\SAS\JMP\11\Samples\Automation\Visual Basic Samples\Data Table .NET\datatab.vb&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I don't have Visual Studio (just Excel), I opened "datatab.vb" with Notepad and attempted to translate the "Subset_Click" procedure from Visual Basic (VB) to Visual Basic for Applications (VBA). Please see the code example below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a few questions:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Why does "doc = app.OpenDocument(fname)" cause a run-time error "Object variable not set"?&lt;/LI&gt;&lt;LI&gt;How do the datatable subset methods work? I can see these in the Excel VBA Object Browser, but there's not much detail.&lt;/LI&gt;&lt;LI&gt;How is the datatable handle used?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000; font-family: courier new,courier;"&gt;'--------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000; font-family: courier new,courier;"&gt;'Subset bigclass by Weight and Height&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000; font-family: courier new,courier;"&gt;'Save new datatable handle in NewDT, then save table to disk as subset.jmp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000; font-family: courier new,courier;"&gt;'--------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Sub Subset()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; Dim app&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; As JMP.Application&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; Dim doc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; As JMP.Document&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; Dim dt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; As JMP.DataTable&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; Dim newDT&amp;nbsp;&amp;nbsp;&amp;nbsp; As JMP.DataTable&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; Dim dtDoc&amp;nbsp;&amp;nbsp;&amp;nbsp; As JMP.Document&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; Dim dir&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; As String&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; Dim fname&amp;nbsp;&amp;nbsp;&amp;nbsp; As String&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; &lt;SPAN style="color: #008000;"&gt;'Start JMP&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; Set app = CreateObject("JMP.Application")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; app.Visible = True&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; &lt;SPAN style="color: #008000;"&gt;'Get data table&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; dir = "C:\Program Files\SAS\JMP\11\Samples\Data\"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; fname = dir &amp;amp; "Big Class.jmp"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; doc = app.OpenDocument(fname)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; dt = doc.GetDataTable&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; &lt;SPAN style="color: #008000;"&gt;'Subset data&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; dt.Activate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; dt.SubsetSetRandomSelection(2, False)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; dt.SubsetStratifyAddColumn ("age")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; dt.AddToSubList ("Name")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; dt.AddToSubList ("Weight")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; dt.AddToSubList ("Height")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; newDT = dt.Subset&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; dtDoc = newDT.Document&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; dtDoc.SaveAs ("C:\JMP\subset.jmp")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;End Sub&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000; font-family: courier new,courier;"&gt;'--------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Sep 2015 19:10:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Excel-VBA-Subset-data-by-column/m-p/14491#M13521</guid>
      <dc:creator>jb</dc:creator>
      <dc:date>2015-09-28T19:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Excel VBA - Subset data by column</title>
      <link>https://community.jmp.com/t5/Discussions/Excel-VBA-Subset-data-by-column/m-p/14492#M13522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi JB,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a full automation reference installed in the Documentation directory where JMP 11 is installed.&amp;nbsp; If you are getting a bad reference, that means either JMP failed to start (App object is empty) or it could not find the Big Class data table and that reference is empty.&amp;nbsp; Please keep in mind that if you are using JMPPro, the directory will be different JMPPRO\11, not JMP\11.&amp;nbsp; The same goes for other JMP products.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This sample is doing a subset, with a Random sample size of 2.&amp;nbsp; Stratify is set, with the age column being used for the stratified sample.&amp;nbsp; Only the selected columns will be output.&amp;nbsp; In this case, name, height and weight are the selected columns.&amp;nbsp; I am attaching a picture of what this would look like if you were to do this interactively.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Brian Corcoran&lt;/P&gt;&lt;P&gt;JMP Development&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Sep 2015 19:32:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Excel-VBA-Subset-data-by-column/m-p/14492#M13522</guid>
      <dc:creator>briancorcoran</dc:creator>
      <dc:date>2015-09-28T19:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Excel VBA - Subset data by column</title>
      <link>https://community.jmp.com/t5/Discussions/Excel-VBA-Subset-data-by-column/m-p/14493#M13523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, there's a lot of good stuff in the JMP install directory! The method descriptions in the Automation Reference PDF are certainly useful.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;In regards to my original questions:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The "Set" keyword was needed to assign an object reference to the variable.&lt;/LI&gt;&lt;LI&gt;Your commentary and picture helped me understand the Subset code.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Sep 2015 22:57:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Excel-VBA-Subset-data-by-column/m-p/14493#M13523</guid>
      <dc:creator>jb</dc:creator>
      <dc:date>2015-09-28T22:57:12Z</dc:date>
    </item>
  </channel>
</rss>

