<?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: JMP Script: New Column for every specified value in column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JMP-Script-New-Column-for-every-specified-value-in-column/m-p/609128#M81040</link>
    <description>&lt;P&gt;Worked for me AND it makes sense. Thank you! I am glad you found this to be "fun".&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Mar 2023 18:34:08 GMT</pubDate>
    <dc:creator>AlphaLion662</dc:creator>
    <dc:date>2023-03-07T18:34:08Z</dc:date>
    <item>
      <title>JMP Script: New Column for every specified value in column</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Script-New-Column-for-every-specified-value-in-column/m-p/609060#M81031</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create new columns for every number value that comes after |90= and label the columns as the string that comes before |90, so the pX or whatever else comes before it. See attached photo below as example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlphaLion662_0-1678202435862.png" style="width: 600px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50797iBB495706A2652B37/image-dimensions/600x60?v=v2" width="600" height="60" role="button" title="AlphaLion662_0-1678202435862.png" alt="AlphaLion662_0-1678202435862.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So, in the first row, I'd like to grab that 93 that comes after "p1|90=", and make a new column labelled "p1". I'd like to do that every number that comes after any and all "pX|90=". That pX might also be sX or rX or pXa/b/c/...and so on. So I'd also like to make new columns for those values as well. The number of data points per row varies greatly, from just one(1) pX|90= value to 15 different pX|90=values, perhaps with some values with sX|90= or rX|90=.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was using the Word function that grabbed pX|00 data values. Now I want to grab just 90, and tried using the previous script I was using for that but found that it wasn't grabbing all of the values I wanted.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlphaLion662_5-1678204879351.png" style="width: 673px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50813i99FD33BE53131B23/image-dimensions/673x37?v=v2" width="673" height="37" role="button" title="AlphaLion662_5-1678204879351.png" alt="AlphaLion662_5-1678204879351.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is for hundreds, soon to be thousands, of rows, so manually doing this isn't tenable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What function(s) makes sense to use here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to JMP scripting, am willing to learn and listen to any ideas. Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:30:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Script-New-Column-for-every-specified-value-in-column/m-p/609060#M81031</guid>
      <dc:creator>AlphaLion662</dc:creator>
      <dc:date>2023-06-08T16:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: JMP Script: New Column for every specified value in column</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Script-New-Column-for-every-specified-value-in-column/m-p/609102#M81035</link>
      <description>&lt;P&gt;No idea if this is the best way but it's fairly straight forward.&amp;nbsp;&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= New Table( "splitting bunches",
	Add Rows( 1 ),
	New Column( "Fun",
		Character,
		"Nominal",
		Set Values( {"&amp;lt;p&amp;gt;p1|00=51;p1|90=32;p2|00=48;p2|90=90;", 
			"&amp;lt;p&amp;gt;p1|00=47;p1|90=60;p4|00=73;p4|90=49;"
		} )
	), 
	
);

dt &amp;lt;&amp;lt; New Column("just_delim", 
// this is just getting rid of that beginning part as I image you don't want it. 
	character, formula(substitute(:Fun, "&amp;lt;p&amp;gt;", ""))
);
// split it on ; into however many columns
dt &amp;lt;&amp;lt; Text To Columns(
	delimiter( ";" ),
	columns( :just_delim )
);
// get the columns you just made
cols_to_stack = (dt &amp;lt;&amp;lt; get Column References)[3::ncols(dt)];
// stack them now 
dt_stack = dt &amp;lt;&amp;lt; Stack(
	columns( cols_to_stack ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Data" ), output table("stacked")
);
// same thing 
dt_stack &amp;lt;&amp;lt; Text To Columns(
	delimiter( "|=" ),
	columns( :Data )
);
dt_stack:"Data 1"n&amp;lt;&amp;lt;Set Name("pX");
dt_stack:"Data 2"n&amp;lt;&amp;lt;Set Name("num_after_pipe");
dt_stack:"Data 3"n&amp;lt;&amp;lt;Set Name("value");

// assuming you want these to be numbers
dt_stack:value &amp;lt;&amp;lt; Set Data Type("Numeric") &amp;lt;&amp;lt; Set Modeling Type("Continuous");

// can now filter out the 90s if you want
rows = dt_stack &amp;lt;&amp;lt; Get Rows Where(:num_after_pipe != "90");
//delete rows
dt_stack &amp;lt;&amp;lt; Delete Rows(rows);

// now just split the table and you should be good. 
dt_split = dt_stack &amp;lt;&amp;lt; Split(
	Split By( :pX ),
	Split( :value ),
	Group( :Fun ),
	Remaining Columns( Drop All ),
	Sort by Column Property
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2023 17:11:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Script-New-Column-for-every-specified-value-in-column/m-p/609102#M81035</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2023-03-07T17:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: JMP Script: New Column for every specified value in column</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Script-New-Column-for-every-specified-value-in-column/m-p/609128#M81040</link>
      <description>&lt;P&gt;Worked for me AND it makes sense. Thank you! I am glad you found this to be "fun".&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 18:34:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Script-New-Column-for-every-specified-value-in-column/m-p/609128#M81040</guid>
      <dc:creator>AlphaLion662</dc:creator>
      <dc:date>2023-03-07T18:34:08Z</dc:date>
    </item>
  </channel>
</rss>

