<?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 How to create a data table of 3 columns per row from numeric string in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-create-a-data-table-of-3-columns-per-row-from-numeric/m-p/737626#M91884</link>
    <description>&lt;P&gt;I'm new to JSL. I have a text string that contains values separated by a "#". The numbers are to be grouped in 3 columns&lt;/P&gt;&lt;P&gt;I know I can write a code to put the values in columns being separated by the "#", but how do I then create a table of 3 values in each row, until the table is complete. I know I'll also probably need to remove the first "#" to prevent issues as first 3 numbers would be in 2nd to 4th column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;#1#0.93#0.99#2#1.92#1.99#3#2.9#2.99#4#3.86#3.98#5#4.85#4.98&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;can go to this:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;0.93&lt;/TD&gt;&lt;TD&gt;0.99&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1.92&lt;/TD&gt;&lt;TD&gt;1.99&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2.9&lt;/TD&gt;&lt;TD&gt;2.99&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;3.86&lt;/TD&gt;&lt;TD&gt;3.98&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;4.85&lt;/TD&gt;&lt;TD&gt;4.98&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;But how do I write the JSL code to get it to this:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Value1&lt;/TD&gt;&lt;TD&gt;Value2&lt;/TD&gt;&lt;TD&gt;Value3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0.93&lt;/TD&gt;&lt;TD&gt;0.99&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1.92&lt;/TD&gt;&lt;TD&gt;1.99&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2.9&lt;/TD&gt;&lt;TD&gt;2.99&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;3.86&lt;/TD&gt;&lt;TD&gt;3.98&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;4.85&lt;/TD&gt;&lt;TD&gt;4.98&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this example there are 5 rows in table but the number of rows could vary.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Mar 2024 11:35:11 GMT</pubDate>
    <dc:creator>godriscoll</dc:creator>
    <dc:date>2024-03-22T11:35:11Z</dc:date>
    <item>
      <title>How to create a data table of 3 columns per row from numeric string</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-a-data-table-of-3-columns-per-row-from-numeric/m-p/737626#M91884</link>
      <description>&lt;P&gt;I'm new to JSL. I have a text string that contains values separated by a "#". The numbers are to be grouped in 3 columns&lt;/P&gt;&lt;P&gt;I know I can write a code to put the values in columns being separated by the "#", but how do I then create a table of 3 values in each row, until the table is complete. I know I'll also probably need to remove the first "#" to prevent issues as first 3 numbers would be in 2nd to 4th column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;#1#0.93#0.99#2#1.92#1.99#3#2.9#2.99#4#3.86#3.98#5#4.85#4.98&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;can go to this:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;0.93&lt;/TD&gt;&lt;TD&gt;0.99&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1.92&lt;/TD&gt;&lt;TD&gt;1.99&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2.9&lt;/TD&gt;&lt;TD&gt;2.99&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;3.86&lt;/TD&gt;&lt;TD&gt;3.98&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;4.85&lt;/TD&gt;&lt;TD&gt;4.98&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;But how do I write the JSL code to get it to this:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Value1&lt;/TD&gt;&lt;TD&gt;Value2&lt;/TD&gt;&lt;TD&gt;Value3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0.93&lt;/TD&gt;&lt;TD&gt;0.99&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1.92&lt;/TD&gt;&lt;TD&gt;1.99&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2.9&lt;/TD&gt;&lt;TD&gt;2.99&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;3.86&lt;/TD&gt;&lt;TD&gt;3.98&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;4.85&lt;/TD&gt;&lt;TD&gt;4.98&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this example there are 5 rows in table but the number of rows could vary.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2024 11:35:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-a-data-table-of-3-columns-per-row-from-numeric/m-p/737626#M91884</guid>
      <dc:creator>godriscoll</dc:creator>
      <dc:date>2024-03-22T11:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a data table of 3 columns per row from numeric string</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-a-data-table-of-3-columns-per-row-from-numeric/m-p/737640#M91885</link>
      <description>&lt;P&gt;Use Text To Columns to get this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1711107560989.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/62518iCD0A754969AA044D/image-size/large?v=v2&amp;amp;px=999" role="button" title="jthi_0-1711107560989.png" alt="jthi_0-1711107560989.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Then stack your data with multiple series stack&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1711107598863.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/62519iC493BB368E5D46B9/image-size/large?v=v2&amp;amp;px=999" role="button" title="jthi_1-1711107598863.png" alt="jthi_1-1711107598863.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and finally remove extra columns, rename column headers and fix column data/modelling types&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1711107678432.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/62520i21BDF580E23871FE/image-size/large?v=v2&amp;amp;px=999" role="button" title="jthi_2-1711107678432.png" alt="jthi_2-1711107678432.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;JMP created script is a good starting point for the final JSL&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Text to columns
Data Table("Untitled 6") &amp;lt;&amp;lt; Text to Columns(columns(:Column 1), Delimiters("#"));


// Stack data table
// → Data Table("Untitled 11")
Data Table("Untitled 6") &amp;lt;&amp;lt; Stack(
	columns(
		:Column 1 1, :Column 1 2, :Column 1 3, :Column 1 4, :Column 1 5, :Column 1 6,
		:Column 1 7, :Column 1 8, :Column 1 9, :Column 1 10, :Column 1 11,
		:Column 1 12, :Column 1 13, :Column 1 14, :Column 1 15
	),
	Source Label Column("Label"),
	Stacked Data Column("Data"),
	Drop All Other Columns(1),
	Number of Series(3),
	Output Table("Untitled 11.jmp")
);


// Delete columns
Data Table("Untitled 11") &amp;lt;&amp;lt; Delete Columns(:Label, :Label 2, :Label 3);


// Recode column names
Local({dt = Data Table("Untitled 11"), names},
	names = Recode(
		dt &amp;lt;&amp;lt; Get Column Names(String),
		{Map Value(
			_rcOrig,
			{"Data", "Value1", "Data 2", "Value2", "Data 3", "Value3"},
			Unmatched(_rcNow)
		)}
	);
	For Each({name, i}, names, Column(dt, i) &amp;lt;&amp;lt; Set Name(name));
);


// Standardize column attributes
Local({old dt = Current Data Table()},
	Current Data Table(Data Table("Untitled 11"));
	For Each({col, index}, {:Value1, :Value2, :Value3},
		col &amp;lt;&amp;lt; Data Type(Numeric, Format("Best", 12)) &amp;lt;&amp;lt;
		Set Modeling Type("Continuous")
	);
	Current Data Table(old dt);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Mar 2024 11:42:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-a-data-table-of-3-columns-per-row-from-numeric/m-p/737640#M91885</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-03-22T11:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a data table of 3 columns per row from numeric string</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-create-a-data-table-of-3-columns-per-row-from-numeric/m-p/737724#M91887</link>
      <description>&lt;P&gt;Here is one approach&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
theString = "#1#0.93#0.99#2#1.92#1.99#3#2.9#2.99#4#3.86#3.98#5#4.85#4.98";

dt = New Table( "Start",
	add rows( 1 ),
	New Column( "string", character, set each value( theString ) )
);
dt &amp;lt;&amp;lt; Text To Columns( delimiter( "#" ), columns( :string ) );
dt &amp;lt;&amp;lt; delete columns( :string );
colNames = dt &amp;lt;&amp;lt; get column names( string );
For Each( {col}, colNames,
	Column( dt, col ) &amp;lt;&amp;lt; Data Type( Numeric, Format( "Best", 12 ) ) &amp;lt;&amp;lt;
	Set Modeling Type( "Continuous" )
);

dt &amp;lt;&amp;lt; Stack(
	columns( colNames ),
	Source Label Column( "Label" ),
	Stacked Data Column( "Value" ),
	Number of Series( 3 ),
	Output Table( "Final" )
);

dtFinal = Current Data Table();
dtFinal &amp;lt;&amp;lt; delete columns( {:Label, :Label2, :Label3} );
dtFinal:value &amp;lt;&amp;lt; set name( "Value 1" );

close( dt, nosave);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1711109674657.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/62527i1E4F24741FFE8973/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1711109674657.png" alt="txnelson_0-1711109674657.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2024 12:14:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-create-a-data-table-of-3-columns-per-row-from-numeric/m-p/737724#M91887</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-03-22T12:14:42Z</dc:date>
    </item>
  </channel>
</rss>

