<?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: Creating a table with formula in the columns - Random Normal() - from external jmp in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Creating-a-table-with-formula-in-the-columns-Random-Normal-from/m-p/429552#M67904</link>
    <description>&lt;P&gt;Thanks! It worked with this code right below. And it helps me a lot!!&lt;/P&gt;&lt;P&gt;However, I'm motivated to learn a bit JSL now. And I tought about a possible implementation. Second code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Clear Globals();
Names Default To Here( 1 );

//mydt = 
//Data Table( "dt_RandomNormalParameter" ) &amp;lt;&amp;lt;
mydt = Current Data Table();

// New data table
my_newdt = New Table( "Table Name", Add Row ( 1000 ));

//lets use formulas, we can easily add more rows if needed
For Each Row(
	mydt,
	columnName = As Column(mydt, "Analysis Columns");
	meanValue = As Column(mydt, "Mean");
	stdDevValue = As Column(mydt, "Std Dev");
	
	//use eval expr to get values in formula
	Eval(Eval Expr(my_newdt &amp;lt;&amp;lt; New Column(columnName, Numeric, Continuous, Formula(Random Normal(Expr(meanValue), Expr(stdDevValue))))));
);

// Code adds Column "Column 1"&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;my concept to solve my problem:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Clear Globals();
Names Default To Here( 1 );

mydt = Current Data Table();

// New data table
my_newdt = New Table( "Table Name",
Add Rows (N Rows ( mydt )), // row count can be set by hand e.g. 1000
	
//For ( i = 1, i &amp;lt;= N Rows ( mydt ), i++, // for loop is not executed

New Column( Column(mydt, 1 )[1] , // Loop i==1
	Numeric,
	"Continuous",
	Format( "Best", 6 ),
	Formula( Random Normal( Column(mydt, :Mean )[1], Column(mydt, :Std Dev )[1] ) )// Column(mydt, :Mean )[1] is not evalueted
				),
New Column( Column(mydt, 1 )[2] , // Loop i ==2
	Numeric,
	"Continuous",
	Format( "Best", 6 ),
	Formula( Random Normal( Column(mydt, :Mean )[2], Column(mydt, :Std Dev )[2] ) )//// Column(mydt, :Mean )[1] is not evalueted
				)				
				
//)// for loop

)// New data table&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Unfortunatelly, I don't know how to use "for loop" inside " New Table" and evaluete index&amp;nbsp; inside Formula.&lt;/P&gt;&lt;P&gt;I assume some how with Eval, Eval Expr.&lt;/P&gt;&lt;P&gt;But I don't understand the syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you believe my concept could work with proper syntax as well?&lt;/P&gt;&lt;P&gt;What needs to be modified?&lt;/P&gt;</description>
    <pubDate>Sat, 23 Oct 2021 14:51:12 GMT</pubDate>
    <dc:creator>Greenhorn</dc:creator>
    <dc:date>2021-10-23T14:51:12Z</dc:date>
    <item>
      <title>Creating a table with formula in the columns - Random Normal() - from external jmp</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-table-with-formula-in-the-columns-Random-Normal-from/m-p/428999#M67848</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;Can somebody help me with a JSL code, which generates a new table with a formula inside the columns properties?&lt;/P&gt;&lt;P&gt;The table size, column names and parameters for the formula comes from an external jmp file like attched.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone share some code snippest, how to start with it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:03:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-table-with-formula-in-the-columns-Random-Normal-from/m-p/428999#M67848</guid>
      <dc:creator>Greenhorn</dc:creator>
      <dc:date>2023-06-09T18:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with formula in the columns - Random Normal() - from external jmp</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-table-with-formula-in-the-columns-Random-Normal-from/m-p/429041#M67851</link>
      <description>&lt;P&gt;You can loop over your RandomNormal_dt.jmp with For Each Row and then get values from the columns. Use &lt;A href="https://community.jmp.com/t5/JSL-Cookbook/Insert-one-expression-into-another-using-Eval-Insert-Eval-Expr/ta-p/48998" target="_blank" rel="noopener"&gt;Eval(EvalExpr()) to add values to Formula.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Names Default To Here(1);

dt_random = New Table("RandomNormal_dt",
	Add Rows(20),
	New Column("Analysis Columns",
		Character(6),
		"Nominal",
		Set Values(
			{"Name1", "Name2", "Name3", "Name4", "Name5", "Name6", "Name7", "Name8", "Name9", "Name10", "Name11", "Name12", "Name13", "Name14","Name15", "Name16", "Name17", "Name18", "Name19", "Name20"}
		),

	),
	New Column("Mean", Numeric, "Continuous", Format("Best", 6), Set Values([1, 1, 0, 0, 0, 2, 2, 3, 3, 5, 10, -5, -6, 3, 3, 3, 3, 3, 0.5, 0.5]), ),
	New Column("Std Dev",
		Numeric,
		"Continuous",
		Format("Best", 6),
		Set Values(
			[0.0059167075785471, 0.00455419279075633, 0.00421951193571742, 0.00421951193571742, 0.00440945078910684, 0.00440945078910684,
			0.0102216984358101, 0.00419398115162298, 0.0808821732109718, 0.0876924473662647, 0.119338972830502, 0.0918654224334168,
			0.0921864791037008, 0.0868549769597964, 0.0808821732109718, 0.0865262154672911, 0.186459394109712, 0.189566585675401, 0.0876924449303901,
			0.0434724818197371]
		),

	)
);

//create collection table
dt = New Table("Analysis");

//lets use formulas, we can easily add more rows if needed
For Each Row(
	dt_random,
	columnName = As Column(dt_random, "Analysis Columns");
	meanValue = As Column(dt_random, "Mean");
	stdDevValue = As Column(dt_random, "Std Dev");
	
	//use eval expr to get values in formula
	Eval(Eval Expr(dt &amp;lt;&amp;lt; New Column(columnName, Numeric, Continuous, Formula(Random Normal(Expr(meanValue), Expr(stdDevValue))))));
);&lt;/CODE&gt;&lt;/PRE&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="jthi_0-1634832801589.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/36889iCD640CC10988AC3B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1634832801589.png" alt="jthi_0-1634832801589.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then you can add rows as needed.After adding rows you can remove formulas to make the datatable faster if needed. If you know how many rows you need, you can replace Formula() with &amp;lt;&amp;lt; Set Each Value() and create the collection with enough rows.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 16:15:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-table-with-formula-in-the-columns-Random-Normal-from/m-p/429041#M67851</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-10-21T16:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with formula in the columns - Random Normal() - from external jmp</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-table-with-formula-in-the-columns-Random-Normal-from/m-p/429552#M67904</link>
      <description>&lt;P&gt;Thanks! It worked with this code right below. And it helps me a lot!!&lt;/P&gt;&lt;P&gt;However, I'm motivated to learn a bit JSL now. And I tought about a possible implementation. Second code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Clear Globals();
Names Default To Here( 1 );

//mydt = 
//Data Table( "dt_RandomNormalParameter" ) &amp;lt;&amp;lt;
mydt = Current Data Table();

// New data table
my_newdt = New Table( "Table Name", Add Row ( 1000 ));

//lets use formulas, we can easily add more rows if needed
For Each Row(
	mydt,
	columnName = As Column(mydt, "Analysis Columns");
	meanValue = As Column(mydt, "Mean");
	stdDevValue = As Column(mydt, "Std Dev");
	
	//use eval expr to get values in formula
	Eval(Eval Expr(my_newdt &amp;lt;&amp;lt; New Column(columnName, Numeric, Continuous, Formula(Random Normal(Expr(meanValue), Expr(stdDevValue))))));
);

// Code adds Column "Column 1"&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;my concept to solve my problem:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Clear Globals();
Names Default To Here( 1 );

mydt = Current Data Table();

// New data table
my_newdt = New Table( "Table Name",
Add Rows (N Rows ( mydt )), // row count can be set by hand e.g. 1000
	
//For ( i = 1, i &amp;lt;= N Rows ( mydt ), i++, // for loop is not executed

New Column( Column(mydt, 1 )[1] , // Loop i==1
	Numeric,
	"Continuous",
	Format( "Best", 6 ),
	Formula( Random Normal( Column(mydt, :Mean )[1], Column(mydt, :Std Dev )[1] ) )// Column(mydt, :Mean )[1] is not evalueted
				),
New Column( Column(mydt, 1 )[2] , // Loop i ==2
	Numeric,
	"Continuous",
	Format( "Best", 6 ),
	Formula( Random Normal( Column(mydt, :Mean )[2], Column(mydt, :Std Dev )[2] ) )//// Column(mydt, :Mean )[1] is not evalueted
				)				
				
//)// for loop

)// New data table&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Unfortunatelly, I don't know how to use "for loop" inside " New Table" and evaluete index&amp;nbsp; inside Formula.&lt;/P&gt;&lt;P&gt;I assume some how with Eval, Eval Expr.&lt;/P&gt;&lt;P&gt;But I don't understand the syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you believe my concept could work with proper syntax as well?&lt;/P&gt;&lt;P&gt;What needs to be modified?&lt;/P&gt;</description>
      <pubDate>Sat, 23 Oct 2021 14:51:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-table-with-formula-in-the-columns-Random-Normal-from/m-p/429552#M67904</guid>
      <dc:creator>Greenhorn</dc:creator>
      <dc:date>2021-10-23T14:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with formula in the columns - Random Normal() - from external jmp</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-table-with-formula-in-the-columns-Random-Normal-from/m-p/429746#M67931</link>
      <description>&lt;P&gt;Is there a specific reason why you would want to create the columns inside New Table()? I'm not sure of it is possible and if it is, it will most likely make the code messier when compared to creating them after New Table().&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 07:07:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-table-with-formula-in-the-columns-Random-Normal-from/m-p/429746#M67931</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-10-25T07:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with formula in the columns - Random Normal() - from external jmp</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-table-with-formula-in-the-columns-Random-Normal-from/m-p/429811#M67937</link>
      <description>&lt;P&gt;The actual script generates a undefined column " Clolumn 1".&amp;nbsp;&lt;/P&gt;&lt;P&gt;And generating columns inside New Table () doesn't create such column. It is just cosmetic...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in mean time, I have a script which has single column definition and the others are added outside the new column.&lt;/P&gt;&lt;P&gt;And the new generated table has correct calculated values. However, if I look inside the Formula then it contains the expression from the script.&lt;/P&gt;&lt;P&gt;I can mask this fact by using&amp;nbsp;&lt;SPAN&gt;Set Each Value(). But it makes me crazy ... :)&lt;/img&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;And now I'm obsessive to understand why the expression is not evaluated properly. I didn't success using Eval () Eval Expr() and Expr(). I believe to undestand their functions but with combination with Formula, no chance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, my initial problem is solved with your proposal. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 11:27:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-table-with-formula-in-the-columns-Random-Normal-from/m-p/429811#M67937</guid>
      <dc:creator>Greenhorn</dc:creator>
      <dc:date>2021-10-25T11:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with formula in the columns - Random Normal() - from external jmp</title>
      <link>https://community.jmp.com/t5/Discussions/Creating-a-table-with-formula-in-the-columns-Random-Normal-from/m-p/429824#M67939</link>
      <description>&lt;P&gt;Removing the Column 1 is easy in script so it shouldn't be a problem. I would either create column with specific name or remove it by using index&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Names Default To Here(1);
dt = New Table("testtable", add rows(1),
	new column("REMOVETHIS")
);
wait(1); //for demonstration purposes&lt;BR /&gt;//dt &amp;lt;&amp;lt; Delete Column(1);
dt &amp;lt;&amp;lt; Delete Columns("REMOVETHIS");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Using Set Each value is better if you have no need for formulas, as it is faster.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For learning... Eval(EvalExpr()) definitely aren't the easiest things to understand, but there are some content which might help. Quickly checking I found these:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://www.jmp.com/support/help/en/16.1/index.shtml#page/jmp/lists-and-expressions.shtml" target="_blank" rel="noopener"&gt;JMP Help - Lists and Expressions&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.jmp.com/t5/Uncharted/Introspection/ba-p/28930" target="_blank" rel="noopener"&gt;Introspection&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://www.google.com/search?hl=en&amp;amp;q=Using%20JSL%20to%20Develop%20Efficient%2C%20Robust%20Applications" target="_blank" rel="noopener"&gt;Using JSL to Develop Efficient, Robust Applications (EU 2018 415)&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://www.jmp.com/support/help/en/16.1/index.shtml#page/jmp/lists-and-expressions.shtml" target="_blank" rel="noopener"&gt;JMP 16 Scripting Guide&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.jmp.com/t5/Uncharted/Introspection/ba-p/28930" target="_blank" rel="noopener"&gt;Expression Handling Functions: Part I - Unraveling the Expr(), NameExpr(), Eval(), ... Conundrum (to my knowledge there is no more parts to this)&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://redshelf.com/app/ecom/book/1878402/jsl-companion-1878402-9781635266115-theresa-utlaut-georgia-morgan-kevin-anderson" target="_blank" rel="noopener"&gt;JSL Companion book&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Mon, 25 Oct 2021 12:07:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Creating-a-table-with-formula-in-the-columns-Random-Normal-from/m-p/429824#M67939</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-10-25T12:07:46Z</dc:date>
    </item>
  </channel>
</rss>

