<?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: JSL scripting to create subset data tables in application builder in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-scripting-to-create-subset-data-tables-in-application/m-p/768286#M94851</link>
    <description>&lt;P&gt;The associative array - with a data table as first argument?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
MET = Open( "$SAMPLE_DATA/Big Class.jmp" );

Factor={"height", "weight"};
Associative Array(MET, Column(Eval List(Factor)))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1719319909046.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65557i892D0E40B7A1278A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1719319909046.png" alt="hogi_0-1719319909046.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jun 2024 12:53:07 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2024-06-25T12:53:07Z</dc:date>
    <item>
      <title>JSL scripting to create subset data tables in application builder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-scripting-to-create-subset-data-tables-in-application/m-p/768026#M94834</link>
      <description>&lt;P&gt;I am trying to develop a JMP add-in for the first time using the application builder, but got stuck with the JSL scripting as described below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some Background:&lt;/P&gt;&lt;P&gt;The interface was built under the Dialog tab.&lt;BR /&gt;There are three panel boxes with the titles of Columns, Roles and Action, and variable names of ColumnsPanel, RolesPanel and ActionPanel, respectively.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Under Columns panel, I added a Col List Box (All) with the variable name of ColList where it pulls into all the columns in the opened data table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Under Roles panel, I added three Col List Boxes and three Button Boxes:&lt;BR /&gt;the variable names for the first, second and third Col List Box are ResponseColList, FactorColList and BlockColList, respectively.&lt;BR /&gt;the variable names for the first, second and third Button Box are ResponseButton, FactorButton and BlockButton, respectively.&lt;BR /&gt;the titles for the first, second and third Button Box are Response, Factor and Block, respectively.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Under the Action panel, I added three Button Boxes with the titles of OK, Remove and Cancel, and variable names of OKButton, RemoveButton and CancelButton, respectively.&lt;BR /&gt;When I click the Response Button, it added the columns of attribute "A", "B", "C", "D" and "E" from ColList.&lt;BR /&gt;Similarily, when I click the Factor and Block Button, it added the column of "Site" and "People" from ColList.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65533i2A8A43B476CEF165/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scripts:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Part I
//Places selected columns into Role panel
On Response = Function({},
		ResponseColList &amp;lt;&amp;lt; Append( AllColList &amp;lt;&amp;lt; Get Selected)
);

//Places selected columns into Factor panel
On Factor = Function({},
		FactorColList &amp;lt;&amp;lt; Append( AllColList &amp;lt;&amp;lt; Get Selected)
);

//Places selected columns into Block panel
On Block = Function({},
		BlockColList &amp;lt;&amp;lt; Append( AllColList &amp;lt;&amp;lt; Get Selected)
);

// Program the OK Button
On OK = Function({},
Response = ResponseColList &amp;lt;&amp;lt; Get Items;
Factor = FactorColList &amp;lt;&amp;lt; Get Items;
Block = BlockColList &amp;lt;&amp;lt; Get Items;

// Get the current data table
    dt = Current Data Table();
    
// Perform principal component analysis
    pca = dt &amp;lt;&amp;lt; Principal Components(
    Y( Eval List( Response ) ),
    Estimation Method( "NIPALS" ),
    Standardize( "Standardized" )
);

pca &amp;lt;&amp;lt; Save Principal Component Values( 3 );
pca &amp;lt;&amp;lt; Close Window();

// Create a subset and delete columns "Prin1", "Prin2" and ""Prin3" in "dt"
dt &amp;lt;&amp;lt; Subset(
        Output Table("MET"),
        All rows,
        columns(Eval List(Block), Eval List(Factor), :Prin1, :Prin2, :Prin3)
    );
    
    dt &amp;lt;&amp;lt; Delete Columns( "Prin1" ) &amp;lt;&amp;lt; Delete Columns( "Prin2" ) &amp;lt;&amp;lt; Delete Columns( "Prin3" );
    
// Standardize column attributes and create a data table "MET"
Current Data Table(Data Table("MET"));
    For Each({col, index}, {:Prin1, :Prin2, :Prin3},
        col &amp;lt;&amp;lt; Format("Fixed Dec", 12, 2)
    );

MET = Data Table( "MET" );


//Part II
//Get the levels in the Factor column
factorLevels = Associative Array(MET, Column(Eval List(Factor))) &amp;lt;&amp;lt; Get Keys;
level1 = factorlevels[1];
level2 = factorlevels[2];

// Create two subsets named "Group1" and "Group2"
MET &amp;lt;&amp;lt; Select Where( Column(Eval List(Factor)) == level1 ) &amp;lt;&amp;lt; Subset( Output Table( "Group1" ), Selected Rows( 1 ), Selected columns only( 0 ) );
MET &amp;lt;&amp;lt; Select Where( Column(Eval List(Factor)) == level2 ) &amp;lt;&amp;lt; Subset( Output Table( "Group2" ), Selected Rows( 1 ), Selected columns only( 0 ) );
Group1 = Data Table( "Group1" );
Group2 = Data Table( "Group2" );

// Access the Site levels in "Group1" and "Group2"
Site_level1 = Column( Group1, "Site" ) &amp;lt;&amp;lt; Get Values;
Site_level2 = Column( Group2 "Site" ) &amp;lt;&amp;lt; Get Values;

);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I can successfully run the Part I scripts but keep getting errors in Part II, so really appreciate some help debugging the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another goal here is to handle datasets with different attribute names (e.g., attribute "F", "G", etc.), I would like to ensure that the script uses the selected column names dynamically rather than hardcoding specific names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 19:03:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-scripting-to-create-subset-data-tables-in-application/m-p/768026#M94834</guid>
      <dc:creator>CoxOcelot805</dc:creator>
      <dc:date>2024-06-24T19:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: JSL scripting to create subset data tables in application builder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-scripting-to-create-subset-data-tables-in-application/m-p/768282#M94850</link>
      <description>&lt;P&gt;Which parts of Part2 are failing and errors are you getting?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 12:41:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-scripting-to-create-subset-data-tables-in-application/m-p/768282#M94850</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-06-25T12:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: JSL scripting to create subset data tables in application builder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-scripting-to-create-subset-data-tables-in-application/m-p/768286#M94851</link>
      <description>&lt;P&gt;The associative array - with a data table as first argument?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
MET = Open( "$SAMPLE_DATA/Big Class.jmp" );

Factor={"height", "weight"};
Associative Array(MET, Column(Eval List(Factor)))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1719319909046.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/65557i892D0E40B7A1278A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1719319909046.png" alt="hogi_0-1719319909046.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 12:53:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-scripting-to-create-subset-data-tables-in-application/m-p/768286#M94851</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-06-25T12:53:07Z</dc:date>
    </item>
  </channel>
</rss>

