<?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: JSL Options for Reordering Columns Numerically in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-Options-for-Reordering-Columns-Numerically/m-p/282332#M54626</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

// Create a new data table with columns that resemble your columns
dt = New Table( "Example" );

// Create a bunch of new columns
For(i=1,i&amp;lt;=100,i++,
	dt &amp;lt;&amp;lt; new column( "Column Data " || char(randominteger(1,10)) || "(" ||
		char(randominteger(1,99)) || ")"
	)
);
// Get rid of columns that are duplicates
For(i=100,i&amp;gt;=1,i--,
	if(substr(column(dt,i)&amp;lt;&amp;lt;get name,length(column(dt,i)&amp;lt;&amp;lt;get name),1)!=")",
		dt &amp;lt;&amp;lt; delete columns(i);
	)
);
wait(5);
// Create a data table of the names and 2 additional columns that will allow for sorting
colNames = dt &amp;lt;&amp;lt; get column names(string);

dtSort = New Table( "Sort Names", New Column( "Name", character, set values(colNames)));
	dtSort &amp;lt;&amp;lt; New Column("Primary Number", formula( Num( Word( -2, :Name, " ()"))));
	dtSort &amp;lt;&amp;lt; New Column("Secondary Number", formula( Num( Word( -1, :Name, " ()"))));
	
// Sort in numerical order
dtSort &amp;lt;&amp;lt; sort(By(:Primary Number, :Secondary Number),order(ascending,ascending), replace table(1));

// Order the columns in the original data table by the order in the sorting table
For(i=1,i&amp;lt;=N Rows(dtSort),i++,
	eval(parse("dt &amp;lt;&amp;lt; go to (:Name(\!"" || column(dtSort,"name")[i] || "\!"));"));
	dt &amp;lt;&amp;lt; move selected columns( To Last );
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Above is a script that first builds a sample data table, and then reorders the columns numerically&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jul 2020 23:22:35 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-07-27T23:22:35Z</dc:date>
    <item>
      <title>JSL Options for Reordering Columns Numerically</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Options-for-Reordering-Columns-Numerically/m-p/282313#M54622</link>
      <description>&lt;P&gt;Are there any options for reordering columns in JSL beyond "Reorder by Name, Modeling Type, Data Type"?&lt;BR /&gt;&lt;BR /&gt;I'm looking to reorder some columns with names and numerical indexing. The columns are named in the following manner- "Column Data 1 (1), Column Data 1 (2), ...., Column Data 99 (1), Column Data 99 (2),...".&lt;BR /&gt;&lt;BR /&gt;Using the reorder by name option basically reorders the data (1), (100), (101), (102),.. ordering it by text rather than numerically.&lt;BR /&gt;&lt;BR /&gt;Are there any options JSL introduces that would make sorting this data simpler? I have ~2200 columns to organize.&lt;/P&gt;&lt;P&gt;Using JMP 14.1.0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:33:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Options-for-Reordering-Columns-Numerically/m-p/282313#M54622</guid>
      <dc:creator>ctwede</dc:creator>
      <dc:date>2023-06-09T23:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Options for Reordering Columns Numerically</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Options-for-Reordering-Columns-Numerically/m-p/282332#M54626</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

// Create a new data table with columns that resemble your columns
dt = New Table( "Example" );

// Create a bunch of new columns
For(i=1,i&amp;lt;=100,i++,
	dt &amp;lt;&amp;lt; new column( "Column Data " || char(randominteger(1,10)) || "(" ||
		char(randominteger(1,99)) || ")"
	)
);
// Get rid of columns that are duplicates
For(i=100,i&amp;gt;=1,i--,
	if(substr(column(dt,i)&amp;lt;&amp;lt;get name,length(column(dt,i)&amp;lt;&amp;lt;get name),1)!=")",
		dt &amp;lt;&amp;lt; delete columns(i);
	)
);
wait(5);
// Create a data table of the names and 2 additional columns that will allow for sorting
colNames = dt &amp;lt;&amp;lt; get column names(string);

dtSort = New Table( "Sort Names", New Column( "Name", character, set values(colNames)));
	dtSort &amp;lt;&amp;lt; New Column("Primary Number", formula( Num( Word( -2, :Name, " ()"))));
	dtSort &amp;lt;&amp;lt; New Column("Secondary Number", formula( Num( Word( -1, :Name, " ()"))));
	
// Sort in numerical order
dtSort &amp;lt;&amp;lt; sort(By(:Primary Number, :Secondary Number),order(ascending,ascending), replace table(1));

// Order the columns in the original data table by the order in the sorting table
For(i=1,i&amp;lt;=N Rows(dtSort),i++,
	eval(parse("dt &amp;lt;&amp;lt; go to (:Name(\!"" || column(dtSort,"name")[i] || "\!"));"));
	dt &amp;lt;&amp;lt; move selected columns( To Last );
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Above is a script that first builds a sample data table, and then reorders the columns numerically&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2020 23:22:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Options-for-Reordering-Columns-Numerically/m-p/282332#M54626</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-07-27T23:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Options for Reordering Columns Numerically</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Options-for-Reordering-Columns-Numerically/m-p/282368#M54634</link>
      <description>&lt;P&gt;Cool!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 01:11:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Options-for-Reordering-Columns-Numerically/m-p/282368#M54634</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2020-07-28T01:11:19Z</dc:date>
    </item>
  </channel>
</rss>

