<?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 What is the recommended format to specify column names for a subset in JSL? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/What-is-the-recommended-format-to-specify-column-names-for-a/m-p/267137#M52017</link>
    <description>&lt;P&gt;When creating a subset table in JSL, column names can most simply be specified with a colon character before the name, as in &lt;CODE class=" language-jsl"&gt;:height&lt;/CODE&gt;. &amp;nbsp;However, if that name has a dash (&lt;FONT face="courier new,courier"&gt;'-'&lt;/FONT&gt;) &amp;nbsp;character in it, that doesn't work. &amp;nbsp;But I find that adding quotes around the name gets it to work. &amp;nbsp;The complete script below demonstrates both methods (though &lt;CODE class=" language-jsl"&gt;Big Class.jmp&lt;/CODE&gt;&amp;nbsp;doesn't contain any column names with dashes).&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" );

scrName = "Col name test script";

dt &amp;lt;&amp;lt; New Script(  // (use of 'New Script' gets script written to data table.)
	scrName,
	//---- create subset with StartTime and given FOMs ----
	dt = Current Data Table();
	dt_subset = dt &amp;lt;&amp;lt; Subset(
		Output Table( "Subset of Big Class" ),
		All Rows,
		Columns(
			:name,		// not in quotes.
			:"height",	// in quotes -- required if col name contains '-'.
			:"weight"	// in quotes -- required if col name contains '-'.
		);
	);
);

// run script to generate graph.
dt &amp;lt;&amp;lt; Run Script( scrName );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And, as desired, this script gets added to the JMP table with the name &lt;CODE class=" language-jsl"&gt;Col name test script&lt;/CODE&gt;. &amp;nbsp;And executing that script from within the JMP table (by selecting its green arrow) properly regenerates the subset table. &amp;nbsp;So far, so good.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But funny things happen if you want to go in and start editing that script (by double-clicking on the script name and opening up the editor). &amp;nbsp;In this case, running the script, as is, from within the script editor fails to add the quoted column names to the subset table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-05-16 at 2.22.27 AM.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24037i98B7A563430B6380/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-05-16 at 2.22.27 AM.png" alt="Screen Shot 2020-05-16 at 2.22.27 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at the script, it seems that double quotes cause column names to get treated as null &lt;CODE class=" language-jsl"&gt;As&amp;nbsp;Column&lt;/CODE&gt; specifications. &amp;nbsp;(It's very strange that the script runs ok from the green arrow, but not from within the script editor; &amp;nbsp;perhaps it's saved internally one way, but gets rendered out to the editor differently??)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, my question is: &amp;nbsp;&lt;STRONG&gt;Is there a recommended way to specify subset column names generally to protect against special characters (like dashes) in the names, but still be able to use the script editor to develop and debug a script?&lt;/STRONG&gt; &amp;nbsp;(I'm actually generating the &lt;CODE class=" language-jsl"&gt;New Script&lt;/CODE&gt;&amp;nbsp;code programmatically, so I don't know ahead of time whether any special characters exist in the names.) &amp;nbsp;I'm running JMP 14.3.0 on Mac OS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 May 2020 09:54:28 GMT</pubDate>
    <dc:creator>SteveTerry</dc:creator>
    <dc:date>2020-05-16T09:54:28Z</dc:date>
    <item>
      <title>What is the recommended format to specify column names for a subset in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/What-is-the-recommended-format-to-specify-column-names-for-a/m-p/267137#M52017</link>
      <description>&lt;P&gt;When creating a subset table in JSL, column names can most simply be specified with a colon character before the name, as in &lt;CODE class=" language-jsl"&gt;:height&lt;/CODE&gt;. &amp;nbsp;However, if that name has a dash (&lt;FONT face="courier new,courier"&gt;'-'&lt;/FONT&gt;) &amp;nbsp;character in it, that doesn't work. &amp;nbsp;But I find that adding quotes around the name gets it to work. &amp;nbsp;The complete script below demonstrates both methods (though &lt;CODE class=" language-jsl"&gt;Big Class.jmp&lt;/CODE&gt;&amp;nbsp;doesn't contain any column names with dashes).&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" );

scrName = "Col name test script";

dt &amp;lt;&amp;lt; New Script(  // (use of 'New Script' gets script written to data table.)
	scrName,
	//---- create subset with StartTime and given FOMs ----
	dt = Current Data Table();
	dt_subset = dt &amp;lt;&amp;lt; Subset(
		Output Table( "Subset of Big Class" ),
		All Rows,
		Columns(
			:name,		// not in quotes.
			:"height",	// in quotes -- required if col name contains '-'.
			:"weight"	// in quotes -- required if col name contains '-'.
		);
	);
);

// run script to generate graph.
dt &amp;lt;&amp;lt; Run Script( scrName );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And, as desired, this script gets added to the JMP table with the name &lt;CODE class=" language-jsl"&gt;Col name test script&lt;/CODE&gt;. &amp;nbsp;And executing that script from within the JMP table (by selecting its green arrow) properly regenerates the subset table. &amp;nbsp;So far, so good.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But funny things happen if you want to go in and start editing that script (by double-clicking on the script name and opening up the editor). &amp;nbsp;In this case, running the script, as is, from within the script editor fails to add the quoted column names to the subset table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-05-16 at 2.22.27 AM.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24037i98B7A563430B6380/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-05-16 at 2.22.27 AM.png" alt="Screen Shot 2020-05-16 at 2.22.27 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at the script, it seems that double quotes cause column names to get treated as null &lt;CODE class=" language-jsl"&gt;As&amp;nbsp;Column&lt;/CODE&gt; specifications. &amp;nbsp;(It's very strange that the script runs ok from the green arrow, but not from within the script editor; &amp;nbsp;perhaps it's saved internally one way, but gets rendered out to the editor differently??)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, my question is: &amp;nbsp;&lt;STRONG&gt;Is there a recommended way to specify subset column names generally to protect against special characters (like dashes) in the names, but still be able to use the script editor to develop and debug a script?&lt;/STRONG&gt; &amp;nbsp;(I'm actually generating the &lt;CODE class=" language-jsl"&gt;New Script&lt;/CODE&gt;&amp;nbsp;code programmatically, so I don't know ahead of time whether any special characters exist in the names.) &amp;nbsp;I'm running JMP 14.3.0 on Mac OS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2020 09:54:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-is-the-recommended-format-to-specify-column-names-for-a/m-p/267137#M52017</guid>
      <dc:creator>SteveTerry</dc:creator>
      <dc:date>2020-05-16T09:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: What is the recommended format to specify column names for a subset in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/What-is-the-recommended-format-to-specify-column-names-for-a/m-p/267140#M52018</link>
      <description>&lt;P&gt;The proper way to reference column names that have special characters in them is with the :Name() function&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");

dt &amp;lt;&amp;lt; new column("Height / Weight", formula(:height / :weight));

colList = dt &amp;lt;&amp;lt; get column names();

show( colList );
/*
colList = {name, age, sex, height, weight, Name("Height / Weight")};
*/

dt &amp;lt;&amp;lt; Distribution( Continuous Distribution( Column( colList[6] ) ) );

show(:Name("height / weight")[1]);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 16 May 2020 10:21:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-is-the-recommended-format-to-specify-column-names-for-a/m-p/267140#M52018</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-05-16T10:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: What is the recommended format to specify column names for a subset in JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/What-is-the-recommended-format-to-specify-column-names-for-a/m-p/267364#M52058</link>
      <description>&lt;P&gt;Yes, that seems to make things work well. &amp;nbsp;Thank you so much, Jim!&lt;/P&gt;&lt;P&gt;For completeness, here is how it turned out.&lt;/P&gt;&lt;P&gt;First, the script that saves a script to the &lt;CODE class=" language-jsl"&gt;Big Class.jmp&lt;/CODE&gt;data table:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

dt &amp;lt;&amp;lt; New Column("Height / Weight", Formula(:height / :weight));
dt &amp;lt;&amp;lt; New Column("Height-Weight",   Formula(:height / :weight));  // using '-'.

scrName = "Col name test script";

dt &amp;lt;&amp;lt; New Script(  // (use of 'New Script' gets script written to data table.)
	scrName,
	// create subset.
	dt = Current Data Table();
	dt_subset = dt &amp;lt;&amp;lt; Subset(
		Output Table( "Subset of Big Class" ),
		All Rows,
		Columns(
			:name,
			:Name("height"),
			:Name("weight"),
			:Name("Height / Weight"),
			:Name("Height-Weight")
		);
	);
);

// run script to create subset.
dt &amp;lt;&amp;lt; Run Script( scrName );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And then, opening up the newly created script in&amp;nbsp;&lt;CODE class=" language-jsl"&gt;Big Class.jmp&lt;/CODE&gt;:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-05-18 at 2.44.37 AM.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24044i0D4674386AECC5D3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-05-18 at 2.44.37 AM.png" alt="Screen Shot 2020-05-18 at 2.44.37 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And, unlike before, when I run this script from this window, it runs as expected.&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 09:49:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/What-is-the-recommended-format-to-specify-column-names-for-a/m-p/267364#M52058</guid>
      <dc:creator>SteveTerry</dc:creator>
      <dc:date>2020-05-18T09:49:58Z</dc:date>
    </item>
  </channel>
</rss>

