<?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 do I conditionally set data type for new column in JSL? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/37940#M22217</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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&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;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jun 2018 19:28:14 GMT</pubDate>
    <dc:creator>mikedriscoll</dc:creator>
    <dc:date>2018-06-08T19:28:14Z</dc:date>
    <item>
      <title>How do I conditionally set data type for new column in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/37940#M22217</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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&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;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 19:28:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/37940#M22217</guid>
      <dc:creator>mikedriscoll</dc:creator>
      <dc:date>2018-06-08T19:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I conditionally set data type for new column in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/37943#M22219</link>
      <description>&lt;P&gt;This will do the trick for you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval(
	Substitute(
			Expr(
				dt &amp;lt;&amp;lt; add multiple columns( "New Column", 1, After( "Name" ), __coltype__ )
			),
		Expr( __colType__ ), Parse( coltype )
	)
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 16:59:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/37943#M22219</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-04-10T16:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I conditionally set data type for new column in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/38156#M22329</link>
      <description>&lt;P&gt;Thanks Jim. That works well. The eval(substitute(expr(...))) has always confused me as to when to use it because it seems an overcomplicated way of getting the variable where it needs to go. Is it fair to say that it is always needed if I'm trying to put a variable into such an expression?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 15:17:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/38156#M22329</guid>
      <dc:creator>mikedriscoll</dc:creator>
      <dc:date>2017-04-14T15:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do I conditionally set data type for new column in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/38157#M22330</link>
      <description>&lt;P&gt;You are correct. &amp;nbsp;This is typically the best way to populate expressions&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 15:19:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/38157#M22330</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-04-14T15:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I conditionally set data type for new column in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/38158#M22331</link>
      <description>Thanks!</description>
      <pubDate>Fri, 14 Apr 2017 15:23:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/38158#M22331</guid>
      <dc:creator>mikedriscoll</dc:creator>
      <dc:date>2017-04-14T15:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I conditionally set data type for new column in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/59783#M32713</link>
      <description>&lt;P&gt;Thank you for reporting this issue. The original post revealed a defect within JSL. A few clever solutions were offered, which were great workarounds. I can report now that in JMP 14, the original code (marked "doesn't work" in the example script) now works correctly and as expected.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 19:26:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/59783#M32713</guid>
      <dc:creator>Audrey_Shull</dc:creator>
      <dc:date>2018-06-08T19:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I conditionally set data type for new column in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/59786#M32716</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 19:38:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-conditionally-set-data-type-for-new-column-in-JSL/m-p/59786#M32716</guid>
      <dc:creator>mikedriscoll</dc:creator>
      <dc:date>2018-06-08T19:38:45Z</dc:date>
    </item>
  </channel>
</rss>

