<?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 to add new column to all data tables in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-add-new-column-to-all-data-tables/m-p/518652#M74474</link>
    <description>&lt;P&gt;Thanks for your response.&lt;/P&gt;&lt;P&gt;I get an error when running this script&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HarriBradbeer_0-1657207596311.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/43801iBDEEF99BAEF223E9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HarriBradbeer_0-1657207596311.png" alt="HarriBradbeer_0-1657207596311.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jul 2022 15:28:20 GMT</pubDate>
    <dc:creator>HarriBradbeer</dc:creator>
    <dc:date>2022-07-07T15:28:20Z</dc:date>
    <item>
      <title>How to add new column to all data tables</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-new-column-to-all-data-tables/m-p/518573#M74468</link>
      <description>&lt;P&gt;I have a series of experiments which produce a text file of results, titled with the name of the sample.&lt;/P&gt;&lt;P&gt;I have a script that takes the data table title and populates a new "sample name" column with the title.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current data table();
name = dt &amp;lt;&amp;lt; get name;
new column("Sample Name");
column(dt,"Sample Name")[1]=name;&lt;BR /&gt;
nr = N Rows( dt );

	For( ii = 2, ii &amp;lt;= nr, ii++,
			If( is missing(Column( dt, "Sample Name" )[ii]),
				Column(dt, "Sample Name" )[ii] = Column( dt, "Sample Name" )[ii - 1]
			);
		);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The experiments are carried out dozens, even hundreds at a time. Is there an adaptation to my script I can put in to make this run on all open data tables so that I can concatenate all the results and continue to automate the analysis?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:03:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-new-column-to-all-data-tables/m-p/518573#M74468</guid>
      <dc:creator>HarriBradbeer</dc:creator>
      <dc:date>2023-06-09T17:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to add new column to all data tables</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-new-column-to-all-data-tables/m-p/518628#M74472</link>
      <description>&lt;P&gt;Do you want to add new column to each of the tables named "Sample Name" and it will contain only the name of that specific data table?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

Open("$SAMPLE_DATA/Big Class.jmp"); // open for demo purposes
Open("$SAMPLE_DATA/Big Class Families.jmp"); // open extra table for demo purposes

new_col_name = "Sample Name";

For Each({dt_cur}, Get Data Table List(),
	name = dt_cur &amp;lt;&amp;lt; get name;
	If(!Contains(dt_cur &amp;lt;&amp;lt; Get Column Names("String"), new_col_name),
		dt_cur &amp;lt;&amp;lt; New Column(new_col_name, Character, Nominal, &amp;lt;&amp;lt; Set Each Value(name));
	);
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1657205506278.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/43800i97F338B08666A41E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1657205506278.png" alt="jthi_1-1657205506278.png" /&gt;&lt;/span&gt;&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>Thu, 07 Jul 2022 15:34:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-new-column-to-all-data-tables/m-p/518628#M74472</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-07-07T15:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to add new column to all data tables</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-new-column-to-all-data-tables/m-p/518652#M74474</link>
      <description>&lt;P&gt;Thanks for your response.&lt;/P&gt;&lt;P&gt;I get an error when running this script&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HarriBradbeer_0-1657207596311.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/43801iBDEEF99BAEF223E9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HarriBradbeer_0-1657207596311.png" alt="HarriBradbeer_0-1657207596311.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 15:28:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-new-column-to-all-data-tables/m-p/518652#M74474</guid>
      <dc:creator>HarriBradbeer</dc:creator>
      <dc:date>2022-07-07T15:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to add new column to all data tables</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-new-column-to-all-data-tables/m-p/518655#M74475</link>
      <description>&lt;P&gt;You are most likely using older version of JMP (For Each was introduced in JMP16). Simple fix is to replace it with For loop (also fixed one typo on the code):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

Open("$SAMPLE_DATA/Big Class.jmp"); // open for demo purposes
Open("$SAMPLE_DATA/Big Class Families.jmp"); // open extra table for demo purposes

new_col_name = "Sample Name";

dt_list = Get Data Table List();
For(i = 1, i &amp;lt;= N Items(dt_list), i++,
	dt_cur = dt_list[i];
	name = dt_cur &amp;lt;&amp;lt; get name;
	If(!Contains(dt_cur &amp;lt;&amp;lt; Get Column Names("String"), new_col_name),
		dt_cur &amp;lt;&amp;lt; New Column(new_col_name, Character, Nominal, &amp;lt;&amp;lt; Set Each Value(name));
	);
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Jul 2022 15:34:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-new-column-to-all-data-tables/m-p/518655#M74475</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-07-07T15:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to add new column to all data tables</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-new-column-to-all-data-tables/m-p/519381#M74535</link>
      <description>&lt;P&gt;If you need each table name only for concatenation, why not let concatenate doing the job, it has an option for this purpose? See Scripting index or help.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Trial1.jmp" );
dt2 = Open( "$SAMPLE_DATA/Trial2.jmp" );
dt &amp;lt;&amp;lt; Concatenate(
	Output Table( "Result Table with Source" ),
	Data Table( "Trial2" ),
	Create Source Column
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Jul 2022 15:15:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-new-column-to-all-data-tables/m-p/519381#M74535</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2022-07-09T15:15:44Z</dc:date>
    </item>
  </channel>
</rss>

