<?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: set data type for new column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/set-data-type-for-new-column/m-p/267899#M52154</link>
    <description>&lt;P&gt;The Add Multiple Columns does not appear to allow for parsing before the actual execution of the statement.&amp;nbsp; Therefore, what is presented as the Add Multiple Columns needs to be fully fleshed out before giving it to JMP for execution.&amp;nbsp; Here are a couple of ways to do that&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
coltype = "character";
Eval(
	Parse(
		Eval Insert(
			"dt &amp;lt;&amp;lt; add multiple columns(\!"New Column\!", 1, After(\!"Name\!"), ^colType^)"
		)
	)
);

// or

Eval(
	Substitute(
			Expr(
				dt &amp;lt;&amp;lt; add multiple columns(
					"New Column",
					1,
					After( "Name" ),
					__type__
				)
			),
		Expr( __type__ ), colType));
	&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 20 May 2020 05:12:33 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-05-20T05:12:33Z</dc:date>
    <item>
      <title>set data type for new column</title>
      <link>https://community.jmp.com/t5/Discussions/set-data-type-for-new-column/m-p/267893#M52152</link>
      <description>&lt;P&gt;Hi, How can I conditionally and programmatically set a data type for a new column? I have a workaround that covers numeric / character, and it could be extended for other types, but I'm trying to get the method below (marked 'not working') to work. The log shows it is not recognizing the type variable. I've tried a few things like parse() but have been so far unsuccessful.&lt;/P&gt;&lt;PRE&gt;Names Default To Here( 1 );

dt = open( "$SAMPLE_DATA\Big Class.jmp");

colType = column(dtData,"Name") &amp;lt;&amp;lt; get data type;

// doesn't work, error on colType
dt &amp;lt;&amp;lt; add multiple columns("New Column", 1, After("Name"), colType);

// works
dt &amp;lt;&amp;lt; add multiple columns("New Column", 1, After("Name"), Numeric);
if(colType == "Character", column(dt, "New Column") &amp;lt;&amp;lt; data type ("Character"));&lt;/PRE&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="simple-translate-button "&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="simple-translate-panel "&gt;&lt;DIV class="simple-translate-result-wrapper"&gt;&lt;P class="simple-translate-result"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="simple-translate-candidate"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 20 May 2020 02:58:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/set-data-type-for-new-column/m-p/267893#M52152</guid>
      <dc:creator>xeqapena</dc:creator>
      <dc:date>2020-05-20T02:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: set data type for new column</title>
      <link>https://community.jmp.com/t5/Discussions/set-data-type-for-new-column/m-p/267899#M52154</link>
      <description>&lt;P&gt;The Add Multiple Columns does not appear to allow for parsing before the actual execution of the statement.&amp;nbsp; Therefore, what is presented as the Add Multiple Columns needs to be fully fleshed out before giving it to JMP for execution.&amp;nbsp; Here are a couple of ways to do that&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
coltype = "character";
Eval(
	Parse(
		Eval Insert(
			"dt &amp;lt;&amp;lt; add multiple columns(\!"New Column\!", 1, After(\!"Name\!"), ^colType^)"
		)
	)
);

// or

Eval(
	Substitute(
			Expr(
				dt &amp;lt;&amp;lt; add multiple columns(
					"New Column",
					1,
					After( "Name" ),
					__type__
				)
			),
		Expr( __type__ ), colType));
	&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 May 2020 05:12:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/set-data-type-for-new-column/m-p/267899#M52154</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-05-20T05:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: set data type for new column</title>
      <link>https://community.jmp.com/t5/Discussions/set-data-type-for-new-column/m-p/267913#M52158</link>
      <description>&lt;P&gt;Jim nailed it; here are a few more ways to construct that statement in case any one resonates better with your code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-MESSAGE title="Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute" uid="48998" url="https://community.jmp.com/t5/JSL-Cookbook/Insert-one-expression-into-another-using-Eval-Insert-Eval-Expr/m-p/48998#U48998" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 10:22:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/set-data-type-for-new-column/m-p/267913#M52158</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2020-05-20T10:22:13Z</dc:date>
    </item>
  </channel>
</rss>

