<?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 can I create a description column with the names cell values and column names? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-can-I-create-a-description-column-with-the-names-cell-values/m-p/637607#M83547</link>
    <description>&lt;P&gt;Here is one way to do what you want.&amp;nbsp; My example shows a hard coded way to solve the problem, and also a more generic method&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1685577481713.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/53310i659CD3DAFADB76CB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1685577481713.png" alt="txnelson_0-1685577481713.png" /&gt;&lt;/span&gt;&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 );

// Script to create the required column when the names of the columns are known
dt = New Table( "Example 1",
	New Column( "A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 1, 2] ) ),
	New Column( "B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2, 2, 5] ) ),
	New Column( "C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [100, 200, 300] ) ),
	New Column( "D", Character, Nominal, Formula( "A = " || Char( :A ) || ": B = " || Char( :B ) || ": C = " || Char( :C ) ) )
);

// Example where script examines the data table and from it, generates the new column
dt2 = New Table( "Example 2",
	New Column( "A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 1, 2] ) ),
	New Column( "B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2, 2, 5] ) ),
	New Column( "C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [100, 200, 300] ) )
);

colNames = dt2 &amp;lt;&amp;lt; get column names( string );
// Build the formula in a string variable
theCMD = "dt2 &amp;lt;&amp;lt; New Column( \!"D\!", character, Nominal, formula(";
For Each( {col, index}, colNames,
	If( index == 1,
		theCMD = theCMD || "\!" " || col,
		theCMD = theCMD || "\!" : " || col
	);
	theCMD = theCMD || " = \!" || Char( :" || col || ") || ";
);
theCMD = theCMD || "));";
Eval( Parse( theCMD ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 31 May 2023 23:58:18 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2023-05-31T23:58:18Z</dc:date>
    <item>
      <title>How can I create a description column with the names cell values and column names?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-I-create-a-description-column-with-the-names-cell-values/m-p/637577#M83535</link>
      <description>&lt;P&gt;I would like to label my graphs with the values and column names for that point (as in a box plot). Currently I do this in Excel by concatenating the column name with the value in the cells. However, if I can do it in JMP, it would save me a significant amount of time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example I may have columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;200&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create a new column that describes the information in the other columns:&lt;/P&gt;&lt;P&gt;A = 1 : B = 2 : C = 100&lt;/P&gt;&lt;P&gt;A = 1 : B = 2 : C = 200&lt;/P&gt;&lt;P&gt;A = 2 : B = 5 : C = 300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I have been able to create a list with the column names, but am unable to figure out how to iterate and concatenate the other values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cdt = Current Data Table();&lt;BR /&gt;ColNames = {};&lt;BR /&gt;ThisLabel = {};&lt;BR /&gt;ColNames = cdt &amp;lt;&amp;lt; Get Column Names( string );&lt;BR /&gt;for(i=3;i&amp;lt;=5;i++)&lt;BR /&gt;concat(ThisLabel,ColNames[i]);&lt;/P&gt;&lt;P&gt;// more work is required to get the values from the table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 21:52:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-I-create-a-description-column-with-the-names-cell-values/m-p/637577#M83535</guid>
      <dc:creator>davek</dc:creator>
      <dc:date>2023-05-31T21:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create a description column with the names cell values and column names?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-I-create-a-description-column-with-the-names-cell-values/m-p/637607#M83547</link>
      <description>&lt;P&gt;Here is one way to do what you want.&amp;nbsp; My example shows a hard coded way to solve the problem, and also a more generic method&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1685577481713.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/53310i659CD3DAFADB76CB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1685577481713.png" alt="txnelson_0-1685577481713.png" /&gt;&lt;/span&gt;&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 );

// Script to create the required column when the names of the columns are known
dt = New Table( "Example 1",
	New Column( "A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 1, 2] ) ),
	New Column( "B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2, 2, 5] ) ),
	New Column( "C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [100, 200, 300] ) ),
	New Column( "D", Character, Nominal, Formula( "A = " || Char( :A ) || ": B = " || Char( :B ) || ": C = " || Char( :C ) ) )
);

// Example where script examines the data table and from it, generates the new column
dt2 = New Table( "Example 2",
	New Column( "A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 1, 2] ) ),
	New Column( "B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2, 2, 5] ) ),
	New Column( "C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [100, 200, 300] ) )
);

colNames = dt2 &amp;lt;&amp;lt; get column names( string );
// Build the formula in a string variable
theCMD = "dt2 &amp;lt;&amp;lt; New Column( \!"D\!", character, Nominal, formula(";
For Each( {col, index}, colNames,
	If( index == 1,
		theCMD = theCMD || "\!" " || col,
		theCMD = theCMD || "\!" : " || col
	);
	theCMD = theCMD || " = \!" || Char( :" || col || ") || ";
);
theCMD = theCMD || "));";
Eval( Parse( theCMD ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 May 2023 23:58:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-I-create-a-description-column-with-the-names-cell-values/m-p/637607#M83547</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-05-31T23:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create a description column with the names cell values and column names?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-I-create-a-description-column-with-the-names-cell-values/m-p/637658#M83549</link>
      <description>&lt;P&gt;If you don't really need the column names, a faster way is to select your 3 columns, then right click one of the column headers and select "New Formula Column -&amp;gt; Character -&amp;gt; Concatenate with Comma".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or if you really do need the names, you can right-click the new column header and select "Formula..." and manually edit the formula to include the column header names.&amp;nbsp; It's slower but doesn't require the JSL step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note, if all your columns are numeric, you might have to add a temporary column that's a character column to get the "Character" option to show up in the "New Formula Column" list.&amp;nbsp; We're hoping this gets streamlined in a future version:&amp;nbsp;&amp;nbsp;&lt;A href="https://community.jmp.com/t5/JMP-Wish-List/Enable-string-concatenation-in-quot-New-Formula-Column-quot-gt/idc-p/582366#M3504" target="_blank"&gt;https://community.jmp.com/t5/JMP-Wish-List/Enable-string-concatenation-in-quot-New-Formula-Column-quot-gt/idc-p/582366#M3504&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 04:13:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-I-create-a-description-column-with-the-names-cell-values/m-p/637658#M83549</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2023-06-01T04:13:19Z</dc:date>
    </item>
  </channel>
</rss>

