<?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 Add prefix to column names (scripting) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Add-prefix-to-column-names-scripting/m-p/226713#M44984</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a a JMP dataset and want to a add the same prefix to all the column names in that dataset, my code below doesn't do quite what I want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = dt &amp;lt;&amp;lt; For( i = 25, i &amp;lt;= N Cols( dt ), i++,
	cName = Column( dt, i ) &amp;lt;&amp;lt; Get Name;
	newname = cName || "Prefix_";
	Column( dt, i ) &amp;lt;&amp;lt; Set Name( newname );
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, a second scenario:&lt;/P&gt;
&lt;P&gt;Imagine the column "sex" in "Big Class" contains Fs only (or Ms).&lt;/P&gt;
&lt;P&gt;How could I the access that contant and use it as a prefix by the help of a utility/macro variable in the code above?&lt;/P&gt;
&lt;P&gt;Cheers, Newbie&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Sep 2019 12:08:39 GMT</pubDate>
    <dc:creator>Newbie2Jumpie</dc:creator>
    <dc:date>2019-09-23T12:08:39Z</dc:date>
    <item>
      <title>Add prefix to column names (scripting)</title>
      <link>https://community.jmp.com/t5/Discussions/Add-prefix-to-column-names-scripting/m-p/226713#M44984</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a a JMP dataset and want to a add the same prefix to all the column names in that dataset, my code below doesn't do quite what I want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = dt &amp;lt;&amp;lt; For( i = 25, i &amp;lt;= N Cols( dt ), i++,
	cName = Column( dt, i ) &amp;lt;&amp;lt; Get Name;
	newname = cName || "Prefix_";
	Column( dt, i ) &amp;lt;&amp;lt; Set Name( newname );
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, a second scenario:&lt;/P&gt;
&lt;P&gt;Imagine the column "sex" in "Big Class" contains Fs only (or Ms).&lt;/P&gt;
&lt;P&gt;How could I the access that contant and use it as a prefix by the help of a utility/macro variable in the code above?&lt;/P&gt;
&lt;P&gt;Cheers, Newbie&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 12:08:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-prefix-to-column-names-scripting/m-p/226713#M44984</guid>
      <dc:creator>Newbie2Jumpie</dc:creator>
      <dc:date>2019-09-23T12:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Add prefix to column names (scripting)</title>
      <link>https://community.jmp.com/t5/Discussions/Add-prefix-to-column-names-scripting/m-p/226727#M44987</link>
      <description>&lt;P&gt;First, For() is a function, not a message for a data table, that does not return a reference to a new data table. Second, why start the loop index at 25? Third, why concatenate a prefix &lt;EM&gt;after&lt;/EM&gt; the name? That result is a suffix.&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" );

prefix = dt:sex[1];

For( i = 1, i &amp;lt;= N Cols( dt ), i++,
	cName = Column( dt, i ) &amp;lt;&amp;lt; Get Name;
	newname = prefix || cName;
	Column( dt, i ) &amp;lt;&amp;lt; Set Name( newname );
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 11:56:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-prefix-to-column-names-scripting/m-p/226727#M44987</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2019-09-23T11:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: Add prefix to column names (scripting)</title>
      <link>https://community.jmp.com/t5/Discussions/Add-prefix-to-column-names-scripting/m-p/226738#M44991</link>
      <description>&lt;P&gt;I'm sorry, Mark. I didn't notice the buffer didn't contain=paste the most recent JSL code variant.&lt;/P&gt;
&lt;P&gt;Anyway, I tweaked it a tiny bit...&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" );
prefix = dt:sex[1];
For( i = 1, i &amp;lt;= N Cols( dt ), i++,
cName = Column( dt, i ) &amp;lt;&amp;lt; Get Name;
newname = prefix ||"_"||cName;
Column( dt, i ) &amp;lt;&amp;lt; Set Name( newname ); );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 13:55:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-prefix-to-column-names-scripting/m-p/226738#M44991</guid>
      <dc:creator>Newbie2Jumpie</dc:creator>
      <dc:date>2019-09-23T13:55:55Z</dc:date>
    </item>
  </channel>
</rss>

