<?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: Extracting a string from a column heading and adding to another in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Extracting-a-string-from-a-column-heading-and-adding-to-another/m-p/827345#M100896</link>
    <description>&lt;P&gt;Also non-scripting option came to my mind.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create stacked table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1736869998933.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71928iB9070A5D2FC9B8D7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1736869998933.png" alt="jthi_0-1736869998933.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Create last word column from Label&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1736870018100.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71929i00B716D7D9762850/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1736870018100.png" alt="jthi_1-1736870018100.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now you have mapping table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1736870041570.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71930iFC56CCC2C4BA0895/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_2-1736870041570.png" alt="jthi_2-1736870041570.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Go back to your original table and Recode column names&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_3-1736870064002.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71931i2558DB863ED16E32/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_3-1736870064002.png" alt="jthi_3-1736870064002.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Use Apply Mapping for Table...&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_4-1736870084056.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71932i789DA6D263E9C3D6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_4-1736870084056.png" alt="jthi_4-1736870084056.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_5-1736870134193.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71933i42FEB14A855DD630/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_5-1736870134193.png" alt="jthi_5-1736870134193.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And click Recode&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_6-1736870182351.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71934i387C8F54DA0DB630/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_6-1736870182351.png" alt="jthi_6-1736870182351.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_7-1736870189240.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71935iB42D129BEBC5992F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_7-1736870189240.png" alt="jthi_7-1736870189240.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Too bad JMP isn't able to create proper script for this automatically as it will just use the mapping values directly in the script so this might be manual process unless you are able to create "full mapping table" somehow to get that filled in to the script&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Recode column names
Local({dt = Data Table("Untitled 2"), names},
	names = Recode(
		dt &amp;lt;&amp;lt; Get Column Names(String),
		{Map Value(
			_rcOrig,
			{"JMP Result 1", "DNA", "JMP Result 2", "Protein"},
			Unmatched(_rcNow)
		)}
	);
	For Each({name, i}, names, Column(dt, i) &amp;lt;&amp;lt; Set Name(name));
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 14 Jan 2025 15:58:43 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2025-01-14T15:58:43Z</dc:date>
    <item>
      <title>Extracting a string from a column heading and adding to another</title>
      <link>https://community.jmp.com/t5/Discussions/Extracting-a-string-from-a-column-heading-and-adding-to-another/m-p/827309#M100888</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have an import script which I use to import results into JMP from excel. The template excel is used by lots of people and is locked for editing. We have two results columns in the excel which are both called "Results - XXX" where XXX is replaced using an excel marco to what is being studied so changes in each file. We also have columns called JMP Result 1 and JMP Result 2 which are equal to the results columns and in number format. which we use as JMP import can't import a scientific number from excel. When I open the excel in JMP I get something like the image below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Katz0801_0-1736863953394.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71926iC45D722F7C065E7A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Katz0801_0-1736863953394.png" alt="Katz0801_0-1736863953394.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm trying to write a script which will extract the word following "Results -" from the column heading and replace the JMP Result Column heading but making sure it replaces the correct heading. so the result would be:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Katz0801_1-1736864116263.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71927i1285575DFC69ECBC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Katz0801_1-1736864116263.png" alt="Katz0801_1-1736864116263.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure if this is possible in JMP but any help would be greatly apricated. Not even sure how to start by extracting the end of the string of the column heading let alone the later steps. Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 14:18:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extracting-a-string-from-a-column-heading-and-adding-to-another/m-p/827309#M100888</guid>
      <dc:creator>Katz0801</dc:creator>
      <dc:date>2025-01-14T14:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a string from a column heading and adding to another</title>
      <link>https://community.jmp.com/t5/Discussions/Extracting-a-string-from-a-column-heading-and-adding-to-another/m-p/827330#M100889</link>
      <description>&lt;P&gt;Here is pure JSL option. It can (and will will) break fairly easily depending on your data as I had to make quite a few assumptions&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(1),
	Compress File When Saved(1),
	New Column("Results - DNA", Numeric, "Continuous", Format("Best", 12), Set Values([.]), ),
	New Column("Results - Protein", Numeric, "Continuous", Format("Best", 12), Set Values([.])),
	New Column("JMP Result 1", Numeric, "Continuous", Format("Best", 12), Set Values([.])),
	New Column("JMP Result 2", Numeric, "Continuous", Format("Best", 12), Set Values([.]))
);

// Assume that you extract last word from result columns
// and results are first then jmp columns and there is equal amount
result_columns = {};
jmp_columns = {};

colnames = dt &amp;lt;&amp;lt; Get Column Names("String");
For Each({colname}, colnames,
	If(Starts With(colname, "Results - "),
		Insert into(result_columns, Word(-1, colname, " "));
	,
		Insert Into(jmp_columns, colname)
	)
);

For Each({{rescol, jmpcol}}, Across(result_columns, jmp_columns),
	Column(dt, jmpcol) &amp;lt;&amp;lt; Set Name(rescol);
);

Write();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jan 2025 14:39:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extracting-a-string-from-a-column-heading-and-adding-to-another/m-p/827330#M100889</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-01-14T14:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a string from a column heading and adding to another</title>
      <link>https://community.jmp.com/t5/Discussions/Extracting-a-string-from-a-column-heading-and-adding-to-another/m-p/827333#M100892</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I attached a test data table. Try this script:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current data table();

	for each({name,i}, dt &amp;lt;&amp;lt; get column names(string),
		if (contains(name, "Results -"),
			new_name_string = word(2, name, "- ");
			column(dt,i) &amp;lt;&amp;lt; set name(substitute(name, "Results -", "Results_Excel -" ));
			for each({name2,p}, dt &amp;lt;&amp;lt; get column names(string),
					if (contains(name2, "JMP Result"),
						column(dt,p) &amp;lt;&amp;lt; set name(new_name_string);
						Break();
						,
						);
					); 
				,
			);
	
	);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This should do what you are aiming for. Please let us know if not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Just saw Jarmos great solution. You might choose this one if you do not want to change the names of the "excel" columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Jonas&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 16:12:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extracting-a-string-from-a-column-heading-and-adding-to-another/m-p/827333#M100892</guid>
      <dc:creator>Jonas_Rinne</dc:creator>
      <dc:date>2025-01-14T16:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a string from a column heading and adding to another</title>
      <link>https://community.jmp.com/t5/Discussions/Extracting-a-string-from-a-column-heading-and-adding-to-another/m-p/827345#M100896</link>
      <description>&lt;P&gt;Also non-scripting option came to my mind.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create stacked table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1736869998933.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71928iB9070A5D2FC9B8D7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1736869998933.png" alt="jthi_0-1736869998933.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Create last word column from Label&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1736870018100.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71929i00B716D7D9762850/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1736870018100.png" alt="jthi_1-1736870018100.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now you have mapping table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1736870041570.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71930iFC56CCC2C4BA0895/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_2-1736870041570.png" alt="jthi_2-1736870041570.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Go back to your original table and Recode column names&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_3-1736870064002.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71931i2558DB863ED16E32/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_3-1736870064002.png" alt="jthi_3-1736870064002.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Use Apply Mapping for Table...&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_4-1736870084056.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71932i789DA6D263E9C3D6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_4-1736870084056.png" alt="jthi_4-1736870084056.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_5-1736870134193.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71933i42FEB14A855DD630/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_5-1736870134193.png" alt="jthi_5-1736870134193.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And click Recode&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_6-1736870182351.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71934i387C8F54DA0DB630/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_6-1736870182351.png" alt="jthi_6-1736870182351.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_7-1736870189240.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71935iB42D129BEBC5992F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_7-1736870189240.png" alt="jthi_7-1736870189240.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Too bad JMP isn't able to create proper script for this automatically as it will just use the mapping values directly in the script so this might be manual process unless you are able to create "full mapping table" somehow to get that filled in to the script&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Recode column names
Local({dt = Data Table("Untitled 2"), names},
	names = Recode(
		dt &amp;lt;&amp;lt; Get Column Names(String),
		{Map Value(
			_rcOrig,
			{"JMP Result 1", "DNA", "JMP Result 2", "Protein"},
			Unmatched(_rcNow)
		)}
	);
	For Each({name, i}, names, Column(dt, i) &amp;lt;&amp;lt; Set Name(name));
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jan 2025 15:58:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extracting-a-string-from-a-column-heading-and-adding-to-another/m-p/827345#M100896</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-01-14T15:58:43Z</dc:date>
    </item>
  </channel>
</rss>

