<?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: How do I apply a script to multiple data tables at a time? (JMP 17) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-apply-a-script-to-multiple-data-tables-at-a-time-JMP-17/m-p/640990#M83821</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/48128"&gt;@Kast&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A follow-up to what&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;mentioned. A script to do this might look like this.&amp;nbsp; The correct expression syntax is still a bit fuzzy to me, but this should be most of the way to what you need.&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_list = Multiple file import(); // Incomplete placeholder

table_script = expr( New script( "Table script name here", // Add new tables scripts with New script()
	Graph Builder( // Incomplete table script graphic script 
		Size( 800, 800 ),
		Show Control Panel( 0 ),
		Variables( X( :Column 1 ) ),
		Elements( Points( X, Y, Legend( 5 ) ) ),
		SendToReport(
			Dispatch(
				{},
				"graph title",
				TextEditBox,
				{Set Text( "Example title" )}
			)
		)
	)
);

Eval( // For each loop adds table_script to each data table named in dt_list
	Eval Expr(
		For Each( {value, index},
			Expr( dt_list[index] &amp;lt;&amp;lt; table_script )
		)
	)
);

Eval( // for loop alternative
	eval expr(
		for( i = 1, i &amp;lt;= N Items( dt_list ), i++, 
			expr( dt_list[i] &amp;lt;&amp;lt; table_script )	
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 09 Jun 2023 19:17:19 GMT</pubDate>
    <dc:creator>StarfruitBob</dc:creator>
    <dc:date>2023-06-09T19:17:19Z</dc:date>
    <item>
      <title>How do I apply a script to multiple data tables at a time? (JMP 17)</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-apply-a-script-to-multiple-data-tables-at-a-time-JMP-17/m-p/640970#M83819</link>
      <description>&lt;P&gt;I'm looking for a way to execute a script across multiple data tables by executing the script once as opposed to executing the script one time per data table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Current Data Flow&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Open reference JMP data table.&lt;/LI&gt;
&lt;LI&gt;Use a 1st script (based on Multiple File Import) to import multiple excel files into multiple JMP data tables (1 Table Per File).
&lt;OL&gt;
&lt;LI&gt;Result: 1 Reference Data Table Open and 2-10+ new JMP Data Tables from import script.&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;Run a &lt;U&gt;2nd script&lt;/U&gt; on each created JMP DataTable to clean up the data and update the created data tables with data from the reference JMP data table.
&lt;OL&gt;
&lt;LI&gt;Result: 1 Reference Data Table and 2-10+ JMP data tables that have been cleaned up (delete columns, add calculated columns, etc) and have been updated (scripted Update data table) with data from the reference data table.&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;I'd like to find a solution where I don't have to manually apply my &lt;FONT color="#000000"&gt;&lt;U&gt;2nd script&lt;/U&gt;&lt;/FONT&gt; individually to each created JMP Data Table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm open to any approaches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've thought about trying to use JMP lists and/or the "For Each" function but I haven't been able to find examples of applying these to data tables. I think I would need to make a list of all open data tables filtered by their name (so I can filter out the reference data table I use to update the data tables of interest), I also don't know how to do this.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thank you for any and all advice and ideas.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:53:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-apply-a-script-to-multiple-data-tables-at-a-time-JMP-17/m-p/640970#M83819</guid>
      <dc:creator>Kast</dc:creator>
      <dc:date>2023-06-09T23:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I apply a script to multiple data tables at a time? (JMP 17)</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-apply-a-script-to-multiple-data-tables-at-a-time-JMP-17/m-p/640981#M83820</link>
      <description>&lt;P&gt;Using For Each is the correct idea. You get the reference to your reference data table when you open it and you get a list of references to other datatables from Multiple File Import (if I remember correctly...). You can then loop over that list by using For Each&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:02:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-apply-a-script-to-multiple-data-tables-at-a-time-JMP-17/m-p/640981#M83820</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-06-09T19:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I apply a script to multiple data tables at a time? (JMP 17)</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-apply-a-script-to-multiple-data-tables-at-a-time-JMP-17/m-p/640990#M83821</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/48128"&gt;@Kast&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A follow-up to what&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;mentioned. A script to do this might look like this.&amp;nbsp; The correct expression syntax is still a bit fuzzy to me, but this should be most of the way to what you need.&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_list = Multiple file import(); // Incomplete placeholder

table_script = expr( New script( "Table script name here", // Add new tables scripts with New script()
	Graph Builder( // Incomplete table script graphic script 
		Size( 800, 800 ),
		Show Control Panel( 0 ),
		Variables( X( :Column 1 ) ),
		Elements( Points( X, Y, Legend( 5 ) ) ),
		SendToReport(
			Dispatch(
				{},
				"graph title",
				TextEditBox,
				{Set Text( "Example title" )}
			)
		)
	)
);

Eval( // For each loop adds table_script to each data table named in dt_list
	Eval Expr(
		For Each( {value, index},
			Expr( dt_list[index] &amp;lt;&amp;lt; table_script )
		)
	)
);

Eval( // for loop alternative
	eval expr(
		for( i = 1, i &amp;lt;= N Items( dt_list ), i++, 
			expr( dt_list[i] &amp;lt;&amp;lt; table_script )	
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:17:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-apply-a-script-to-multiple-data-tables-at-a-time-JMP-17/m-p/640990#M83821</guid>
      <dc:creator>StarfruitBob</dc:creator>
      <dc:date>2023-06-09T19:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I apply a script to multiple data tables at a time? (JMP 17)</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-apply-a-script-to-multiple-data-tables-at-a-time-JMP-17/m-p/641990#M83899</link>
      <description>&lt;P&gt;Thank you both. Really appreciate the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt_list = Multiple File Import()&lt;/CODE&gt;; //with all Multiple File Import details included&lt;BR /&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;definitely works for making the list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wasn't able to get this to work for myself, but I'm still learning how to use Eval, EvalExpr, Expr, etc.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval( // For each loop adds table_script to each data table named in dt_list
	Eval Expr(
		For Each( {value, index},
			Expr( dt_list[index] &amp;lt;&amp;lt; table_script )
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I was able to get a simple test to work with For Each in this format. Simple added column script.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For Each({listitem}, dt_list, listitem &amp;lt;&amp;lt; New Column( "Mean",
	Numeric,
	"Continuous",
	Formula( Mean( :A, :B, :C, :D&lt;/img&gt; ) ),
	Format( "Best", 12 )));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My complete working example code is&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);

dt_list = Multiple File Import(
	&amp;lt;&amp;lt;Set Folder(Get Default Directory();),
	&amp;lt;&amp;lt;Set Show Hidden( 0 ),
	&amp;lt;&amp;lt;Set Subfolders( 0 ),
	&amp;lt;&amp;lt;Set Name Filter( "*.xlsx; " ),
	&amp;lt;&amp;lt;Set Name Enable( 1 ),
	&amp;lt;&amp;lt;Set Size Enable( 0 ),
	&amp;lt;&amp;lt;Set Date Enable( 0 ),
	&amp;lt;&amp;lt;Set Add File Name Column( 1 ),
	&amp;lt;&amp;lt;Set Add File Size Column( 0 ),
	&amp;lt;&amp;lt;Set Add File Date Column( 0 ),
	&amp;lt;&amp;lt;Set Import Mode( "CSVData" ),
	&amp;lt;&amp;lt;Set Charset( "Best Guess" ),
	&amp;lt;&amp;lt;Set Stack Mode( "Table Per File" ),
	&amp;lt;&amp;lt;Set CSV Has Headers( 1 ),
	&amp;lt;&amp;lt;Set CSV Allow Numeric( 1 ),
	&amp;lt;&amp;lt;Set CSV First Header Line( 1 ),
	&amp;lt;&amp;lt;Set CSV Number Of Header Lines( 1 ),
	&amp;lt;&amp;lt;Set CSV First Data Line( 2 ),
	&amp;lt;&amp;lt;Set CSV EOF Comma( 1 ),
	&amp;lt;&amp;lt;Set CSV EOF Tab( 0 ),
	&amp;lt;&amp;lt;Set CSV EOF Space( 0 ),
	&amp;lt;&amp;lt;Set CSV EOF Spaces( 0 ),
	&amp;lt;&amp;lt;Set CSV EOF Other( "" ),
	&amp;lt;&amp;lt;Set CSV EOL CRLF( 1 ),
	&amp;lt;&amp;lt;Set CSV EOL CR( 1 ),
	&amp;lt;&amp;lt;Set CSV EOL LF( 1 ),
	&amp;lt;&amp;lt;Set CSV EOL Semicolon( 0 ),
	&amp;lt;&amp;lt;Set CSV EOL Other( "" ),
	&amp;lt;&amp;lt;Set CSV Quote( "\!"" ),
	&amp;lt;&amp;lt;Set CSV Escape( "" ),
	&amp;lt;&amp;lt;Set XML Method( "guess" ),
	&amp;lt;&amp;lt;Set XML Guess( "huge" ),
	&amp;lt;&amp;lt;Set XML Settings( XML Settings() ),
	&amp;lt;&amp;lt;Set JSON Method( "guess" ),
	&amp;lt;&amp;lt;Set JSON Guess( "huge" ),
	&amp;lt;&amp;lt;Set JSON Settings( JSON Settings() ),
	&amp;lt;&amp;lt;Set PDF Method( "guess" ),
	&amp;lt;&amp;lt;Set PDF Settings( PDF All Tables( Combine( All ) ) ),
	&amp;lt;&amp;lt;Set Import Callback( Empty() )
) &amp;lt;&amp;lt; Import Data;

For Each({listitem}, dt_list, listitem &amp;lt;&amp;lt; New Column( "Mean",
	Numeric,
	"Continuous",
	Formula( Mean( :A, :B, :C, :D&lt;/img&gt; ) ),
	Format( "Best", 12 )));

&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 21:41:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-apply-a-script-to-multiple-data-tables-at-a-time-JMP-17/m-p/641990#M83899</guid>
      <dc:creator>Kast</dc:creator>
      <dc:date>2023-06-13T21:41:52Z</dc:date>
    </item>
  </channel>
</rss>

