<?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 Delete Columns with Formula Reference in JSL in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/6983#M6977</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a script where I would like to delete columns that contain a formula reference.&amp;nbsp; This is easy to do in JMP: when delete the unnecessary columns I get a "JMP Alert" and select "Remove Formula".&amp;nbsp; I am then able to delete my metadata columns, but the table maintains the result calculated in the formula column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My problem is: how can I script this?&amp;nbsp; Is there an option to delete a metadata column that contains a formula reference?&amp;nbsp; I am using JMP10.&amp;nbsp; Please see the example below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/*
bigClass = Open( "$SAMPLE_DATA/Big Class.jmp" );
bigClass &amp;lt;&amp;lt; New Column( "height / weigh", Numeric, Continuous, Format( "Best", 12 ), Formula( :height / :weight ) );
bigClass &amp;lt;&amp;lt; Delete Column( "height" );
bigClass &amp;lt;&amp;lt; Delete Column( "weight" );
*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 07 Mar 2018 14:08:17 GMT</pubDate>
    <dc:creator>robot</dc:creator>
    <dc:date>2018-03-07T14:08:17Z</dc:date>
    <item>
      <title>Delete Columns with Formula Reference in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/6983#M6977</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a script where I would like to delete columns that contain a formula reference.&amp;nbsp; This is easy to do in JMP: when delete the unnecessary columns I get a "JMP Alert" and select "Remove Formula".&amp;nbsp; I am then able to delete my metadata columns, but the table maintains the result calculated in the formula column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My problem is: how can I script this?&amp;nbsp; Is there an option to delete a metadata column that contains a formula reference?&amp;nbsp; I am using JMP10.&amp;nbsp; Please see the example below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/*
bigClass = Open( "$SAMPLE_DATA/Big Class.jmp" );
bigClass &amp;lt;&amp;lt; New Column( "height / weigh", Numeric, Continuous, Format( "Best", 12 ), Formula( :height / :weight ) );
bigClass &amp;lt;&amp;lt; Delete Column( "height" );
bigClass &amp;lt;&amp;lt; Delete Column( "weight" );
*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 14:08:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/6983#M6977</guid>
      <dc:creator>robot</dc:creator>
      <dc:date>2018-03-07T14:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Columns with Formula Reference in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/6984#M6978</link>
      <description>&lt;P&gt;Never mind.&amp;nbsp; I found the answer:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.jmp.com/message/48129#48129" target="_blank"&gt;https://community.jmp.com/message/48129#48129&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 14:10:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/6984#M6978</guid>
      <dc:creator>robot</dc:creator>
      <dc:date>2018-03-07T14:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Columns with Formula Reference in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/52719#M29850</link>
      <description>&lt;P&gt;Can you tell me how you solved this problem?&amp;nbsp; I have tried to remove formula, but this removed the values in the original column.&amp;nbsp; I need to delete a column contains a column reference.&amp;nbsp; Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 13:21:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/52719#M29850</guid>
      <dc:creator>DonHil</dc:creator>
      <dc:date>2018-03-07T13:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Columns with Formula Reference in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/54406#M30749</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11221"&gt;@DonHil&lt;/a&gt;&amp;nbsp;Column("column name") &amp;lt;&amp;lt; delete formula;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 19:01:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/54406#M30749</guid>
      <dc:creator>powerpuff</dc:creator>
      <dc:date>2018-04-03T19:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Columns with Formula Reference in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/274537#M53245</link>
      <description>&lt;P&gt;This is kind of old, but I have an addition to this and I figure I'll try here first :)&lt;/img&gt;&lt;BR /&gt;&lt;BR /&gt;What if I don't know the columns with formula that will be referencing the column i want to delete. I am trying to make something dynamic, and I would like to precode it so it wilkl automatically delete the formula if there is a conflict (just like if i did it manually), but I can't find any syntax that allows for that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the "easiest" method is to just remove all formulas so it's never an issue, but that seems a bit more extreme than it needs to be.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 20:22:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/274537#M53245</guid>
      <dc:creator>nathan-clark</dc:creator>
      <dc:date>2020-06-19T20:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Columns with Formula Reference in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/469123#M71293</link>
      <description>&lt;P&gt;Hi Nathan,&lt;/P&gt;&lt;P&gt;Did you find a solution to your posted question/problem?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to do the same... I'd like to delete a column that is used in a formula in one or more other columns.&lt;/P&gt;&lt;P&gt;I want to make it dynamic rather than specifying a&amp;nbsp;"&lt;SPAN&gt;col &amp;lt;&amp;lt; delete formula"&lt;/SPAN&gt; statement for a particular column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2022 20:46:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/469123#M71293</guid>
      <dc:creator>rbfinner</dc:creator>
      <dc:date>2022-03-11T20:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Columns with Formula Reference in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/470258#M71433</link>
      <description>&lt;P&gt;I have not found a solution yet. The most painful to code that I've come up with would be to essentially grab all the formulas and create a map of formula column to the local variables necessary for that formula. That could then be used dynamically when column deletions need to be done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I assume something like that is the basis for how JMP knows to trigger the warning in the first place. It would take me some time to come up with something clean for the above, so ideally, JMP could create a JSL function to give us a boolean capability or something :)&lt;/img&gt; I will probably end up chatting with JMP support for a more official solution (or ask for one in the wish list).&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 13:11:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/470258#M71433</guid>
      <dc:creator>nathan-clark</dc:creator>
      <dc:date>2022-03-16T13:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Delete Columns with Formula Reference in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/470272#M71437</link>
      <description>&lt;P&gt;Turns out I did already submit something of this nature to the JMP wish list, and was in touch with JMP support (no clear solution as of yet, but a workaround I haven't had time to integrate quite yet).&lt;BR /&gt;Wish List item:&amp;nbsp;&lt;LI-MESSAGE title="Dynamic formula removal" uid="275631" url="https://community.jmp.com/t5/JMP-Wish-List/Dynamic-formula-removal/m-p/275631#U275631" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A couple work around options from my chats with JMP support.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to here(1);
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt &amp;lt;&amp;lt; New Column( "Test 1", Numeric, Formula( :height + :weight ) );
dt &amp;lt;&amp;lt; New Column( "Test 2", Numeric, Formula( :height + :age ) );
 
keepCols = AssociativeArray({"name","Test 1","sex"});
 
formList = {};
formCols = {};
for(i=1,i&amp;lt;=ncol(dt),i++,
       if(IsEmpty(Column(dt,i) &amp;lt;&amp;lt; get formula),
              Empty()
              ,
              insertInto(formList,Column(dt,i) &amp;lt;&amp;lt; get formula);
              insertinto(formCols,i);
       );
       show(formList,formCols)
);
 
existingCols = dt &amp;lt;&amp;lt; get column names(string);
For(i=1,i&amp;lt;=nitems(existingCols), i++,
 
       there = keepCols[existingCols[i]];
       If(there == 0,
              for(j=1,j&amp;lt;=nitems(formList),j++,
                     nowCol = existingCols[i];
                     If(Contains(char(formList[j]),nowCol) &amp;gt; 0,
                           Print(nowCol);
                           //show(formCols[j]);
                           Try(Column(dt,formCols[j]) &amp;lt;&amp;lt; delete formula);
                           ,
                           Empty()
                     )
              );
              //dt &amp;lt;&amp;lt; delete columns(eval(existingCols[i]))
       )
);
For(i=1,i&amp;lt;=nitems(existingCols), i++,
 
       there = keepCols[existingCols[i]];
       If(there == 0,
              dt &amp;lt;&amp;lt; delete columns(eval(existingCols[i]))
       )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt &amp;lt;&amp;lt; New Column( "Test 1", Numeric, Formula( :height + :weight ) );
colList = {:age, :height, :name};
colListStr = {"age", "height", "name"};
failed = {};
 
//dt &amp;lt;&amp;lt; Delete Columns( :age );  //works
//dt &amp;lt;&amp;lt; Delete Columns( colList[1] );  //fails
//dt &amp;lt;&amp;lt; Delete Columns( Column( colListStr[1] ) ); //works
 
For( i = 1, i &amp;lt;= N Items( colList ), i++,
    //dt &amp;lt;&amp;lt; Clear Column Selection;
    //colList[i] &amp;lt;&amp;lt; Set Selected;
    str = "";
//str = Log Capture( dt &amp;lt;&amp;lt; Delete Columns( colList[i] ) ); //fails
    //str = Log Capture( dt &amp;lt;&amp;lt; Delete Columns() ); //works for selected columns
    str = Log Capture( dt &amp;lt;&amp;lt; Delete Columns( Column( colListStr[i] ) ) ); //works
    Show( str );
    If( str != "",
        Insert Into( failed, colList[i] )
    );
);
Show( failed );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 17:20:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Delete-Columns-with-Formula-Reference-in-JSL/m-p/470272#M71437</guid>
      <dc:creator>nathan-clark</dc:creator>
      <dc:date>2022-03-16T17:20:48Z</dc:date>
    </item>
  </channel>
</rss>

