<?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: Create/ add new columns using veribles in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/825707#M100603</link>
    <description>&lt;P&gt;Since JMP 18 the parallel creation of new columns got very easy - just have a look at&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discussions/Formula/td-p/822455" target="_blank" rel="noopener"&gt;Discussions/Formula/&lt;/A&gt;&amp;nbsp;- feature #3.&lt;BR /&gt;&lt;BR /&gt;In short:&lt;BR /&gt;Select the columns which you want to use as input, then right click on a column header and click&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;new formula column&lt;/FONT&gt; /&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discussions/Formula/td-p/822455" target="_blank" rel="noopener"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1735849178996.png" style="width: 116px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71647i9EC51DFD9CC6E20A/image-dimensions/116x26?v=v2" width="116" height="26" role="button" title="hogi_0-1735849178996.png" alt="hogi_0-1735849178996.png" /&gt;&lt;/span&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;As a last step, key in your formula and click on&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_2-1735849401521.png" style="width: 80px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71649iF99EC65FBB937ACD/image-dimensions/80x46?v=v2" width="80" height="46" role="button" title="hogi_2-1735849401521.png" alt="hogi_2-1735849401521.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;... maybe, with a trick one can even use different parameters for the different columns?&lt;/P&gt;</description>
    <pubDate>Fri, 03 Jan 2025 08:26:36 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2025-01-03T08:26:36Z</dc:date>
    <item>
      <title>Create/ add new columns using veribles</title>
      <link>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/825692#M100601</link>
      <description>&lt;P&gt;Hey guys, I apologize for the confusing title. I wasn't sure how to phrase it.&lt;BR /&gt;My question is: I have a code in which I'm adding new columns using long conditions.&lt;/P&gt;&lt;P&gt;The conditions are the same for all the columns, except to one parameter that changes.&lt;BR /&gt;Is there a way, instead writing each time the full code and the conditions with the new parameter value, create a template (like a function) that I will use a variable instead of the parameter to which I'll send each time the needed value for the conditions of the new column?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2025 17:01:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/825692#M100601</guid>
      <dc:creator>Stas</dc:creator>
      <dc:date>2025-01-02T17:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create/ add new columns using veribles</title>
      <link>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/825702#M100602</link>
      <description>&lt;P&gt;You can use functions or expressions for something like this&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/18.0/#page/jmp/advanced-expressions-macros-and-lists.shtml#ww339382" target="_blank"&gt;https://www.jmp.com/support/help/en/18.0/#page/jmp/advanced-expressions-macros-and-lists.shtml#ww339382&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/18.0/#page/jmp/advanced-functions.shtml#" target="_blank"&gt;https://www.jmp.com/support/help/en/18.0/#page/jmp/advanced-functions.shtml#&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;LI-MESSAGE title="Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute" uid="48998" url="https://community.jmp.com/t5/JSL-Cookbook-Archived/Insert-one-expression-into-another-using-Eval-Insert-Eval-Expr/m-p/48998#U48998" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2025 17:13:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/825702#M100602</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-01-02T17:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create/ add new columns using veribles</title>
      <link>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/825707#M100603</link>
      <description>&lt;P&gt;Since JMP 18 the parallel creation of new columns got very easy - just have a look at&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discussions/Formula/td-p/822455" target="_blank" rel="noopener"&gt;Discussions/Formula/&lt;/A&gt;&amp;nbsp;- feature #3.&lt;BR /&gt;&lt;BR /&gt;In short:&lt;BR /&gt;Select the columns which you want to use as input, then right click on a column header and click&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;new formula column&lt;/FONT&gt; /&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discussions/Formula/td-p/822455" target="_blank" rel="noopener"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1735849178996.png" style="width: 116px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71647i9EC51DFD9CC6E20A/image-dimensions/116x26?v=v2" width="116" height="26" role="button" title="hogi_0-1735849178996.png" alt="hogi_0-1735849178996.png" /&gt;&lt;/span&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;As a last step, key in your formula and click on&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_2-1735849401521.png" style="width: 80px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71649iF99EC65FBB937ACD/image-dimensions/80x46?v=v2" width="80" height="46" role="button" title="hogi_2-1735849401521.png" alt="hogi_2-1735849401521.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;... maybe, with a trick one can even use different parameters for the different columns?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2025 08:26:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/825707#M100603</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-01-03T08:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create/ add new columns using veribles</title>
      <link>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/825709#M100604</link>
      <description>&lt;P&gt;If you want to use exactly the same formula again and again via the new formula right click menu, you can create your own "custom function" and enable the Transform Category option to make it show up in the menu.&lt;BR /&gt;After a restart the code has to be executed again, so include it in an AddIn or in your startup scripts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
myAdd =
New Custom Function(
	"custom",
	"Add",
	Function( {x, y = 1},
		x + y - 1
	)
);
myAdd &amp;lt;&amp;lt; Transform Category( 1 );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;from scripting Index:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_3-1735849930634.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71650i64A2878065271335/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_3-1735849930634.png" alt="hogi_3-1735849930634.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But this approach is very "static".&amp;nbsp;To get the possibility to change a parameter, you have to vote here:&lt;BR /&gt;&lt;LI-MESSAGE title="New Formula Column menu: user-Defined mini GUIs" uid="609877" url="https://community.jmp.com/t5/JMP-Wish-List/New-Formula-Column-menu-user-Defined-mini-GUIs/m-p/609877#U609877" 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;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2025 07:44:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/825709#M100604</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-01-03T07:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create/ add new columns using veribles</title>
      <link>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/825716#M100609</link>
      <description>&lt;P&gt;Here is one example of function which will add a number. It is missing some checks to be a "good" function but does provide the necessary idea that values which might change (column name and number to add in this case) must be evaluated (see &lt;EM&gt;Insert one expression into another...&lt;/EM&gt; I mentioned earlier)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

cols = {"height", "weight"};

add_num_to_col = Function({dt, colname, num_to_add}, {Default Local},
	new_col = Eval(EvalExpr(
		dt &amp;lt;&amp;lt; New Column(colname || " add " || char(num_to_add), Numeric, Continuous, Formula(
			Expr(NameExpr(AsColumn(dt, colname))) + Expr(num_to_add)
		));
	));
	
	return(new_col);
);

col1 = add_num_to_col(dt, "height", 10);
col2 = add_num_to_col(dt, "height", 20);
col3 = add_num_to_col(dt, "weight", 5);

Write();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sometimes using Eval(Substitute()) is cleaner and easier to understand solution and it could look something like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;add_num_to_col = Function({dt, colname, num_to_add}, {Default Local},
	new_col = Eval(Substitute(
		Expr(dt &amp;lt;&amp;lt; New Column(colname || " add " || char(num_to_add), Numeric, Continuous, Formula(
			_colname_ + _num_to_add_
		))),
		Expr(_colname_), Name Expr(AsColumn(dt, colname)),
		Expr(_num_to_add_), num_to_add
	));
	
	return(new_col);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Jan 2025 06:13:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/825716#M100609</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-01-03T06:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Create/ add new columns using veribles</title>
      <link>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/825731#M100613</link>
      <description>&lt;P&gt;A combination of the previous approaches - with a little &lt;STRONG&gt;twist&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;create a custom function *)&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;add it to a formula category&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;right click on a column header and click&amp;nbsp;&lt;FONT face="courier new,courier"&gt;new formula column&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;/&amp;nbsp;&lt;/SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1735893323385.png" style="width: 102px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71652i8957FBB8A11AE8DD/image-dimensions/102x23?v=v2" width="102" height="23" role="button" title="hogi_0-1735893323385.png" alt="hogi_0-1735893323385.png" /&gt;&lt;/span&gt;&lt;/LI&gt;&lt;LI&gt;use the new formula&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;... and enter the parameter manually:&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_1-1735893371044.png" style="width: 526px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71653i645DEF070A51CD10/image-dimensions/526x300?v=v2" width="526" height="300" role="button" title="hogi_1-1735893371044.png" alt="hogi_1-1735893371044.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*)&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Add Custom Functions(
	New Custom Function(
		"custom",
		"add++",
		Function( {column, num_to_add},
			{Default Local},
			column,
			num_to_add
		),
		&amp;lt;&amp;lt;Formula Category( "NumberStuff" )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The benefit: the user can enter specific parameters for every new column.&lt;/P&gt;&lt;P&gt;The disadvantage: no &lt;STRONG&gt;&lt;EM&gt;batch&lt;/EM&gt; &lt;/STRONG&gt;mode like in the previous posts.&lt;BR /&gt;&lt;BR /&gt;kind of disadvantage: JMP doesn't &lt;EM&gt;resolve/replace&lt;/EM&gt; the formula, it keeps it as &lt;FONT face="courier new,courier"&gt;add++(...)&lt;/FONT&gt;.&lt;BR /&gt;&amp;nbsp; &amp;nbsp;To keep it alive the formula definition has to be executed again after a restart of JMP - and maybe:&amp;nbsp; shared with colleagues.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2025 08:44:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/825731#M100613</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-01-03T08:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create/ add new columns using veribles</title>
      <link>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/826374#M100733</link>
      <description>&lt;P&gt;Thank you everyone for the help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a new related issue that perhaps someone can explain to me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the following method to delete rows with no data in a specific column:&lt;BR /&gt;dt &amp;lt;&amp;lt; select where( Is missing( Column( dt,col_name )[row()] ));&lt;/P&gt;&lt;P&gt;*As a result, it does delete the correct rows, but at the same time it deletes the values in the column. Can someone point me to the mistake?&lt;BR /&gt;Attaching here the script itself:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 03:33:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/826374#M100733</guid>
      <dc:creator>Stas</dc:creator>
      <dc:date>2025-01-09T03:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create/ add new columns using veribles</title>
      <link>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/826375#M100734</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

col_name="x";

New column(col_name); // maybe another column with the same name?
new_col = New column(col_name, Formula(if(:height&amp;gt;60,1 )));

// get the correct column name - uncomment to make it work
//col_name = new_col &amp;lt;&amp;lt; get name();

dt &amp;lt;&amp;lt; select where(  Is missing( Column( dt,col_name )[row()] ));
wait(1);
dt  &amp;lt;&amp;lt; delete  rows;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 03:57:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/826375#M100734</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-01-09T03:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Create/ add new columns using veribles</title>
      <link>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/826376#M100735</link>
      <description>&lt;P&gt;I don't recommend using strings to refer to columns. It happens so often that the actual column is created by adding a "2" - and the string will lead to another column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you generate the column, you get a handle for the column. Just use this handle - and it will guide you to the right column:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

col_name="x";
new_col = New column(col_name, Formula(if(:height&amp;gt;60,1 )));

dt &amp;lt;&amp;lt; select where(  Is missing( new_Col[]  ));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Jan 2025 04:04:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/826376#M100735</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-01-09T04:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create/ add new columns using veribles</title>
      <link>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/826377#M100736</link>
      <description>&lt;P&gt;I also don't like the &lt;FONT face="courier new,courier"&gt;[]&lt;/FONT&gt; to replace the column&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Column(col_name)&lt;/FONT&gt; with the current value&amp;nbsp;&amp;nbsp;&lt;FONT face="courier new,courier"&gt;As column(col_name)&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;:col can do both - and I learned from&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

col_name="x";
new_col = New column(col_name, Formula(if(:height&amp;gt;60,1 )));

myCol = Name Expr(As Column(new_col)); // very cool trick (c) Jarmo
Show(Name Expr(myCol));
dt &amp;lt;&amp;lt; select where(  Is missing( myCol  ));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Jan 2025 04:07:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-add-new-columns-using-veribles/m-p/826377#M100736</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-01-09T04:07:26Z</dc:date>
    </item>
  </channel>
</rss>

