<?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 to story the current filename as entries in a new variable in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-store-the-current-filename-as-entries-in-a-new-variable/m-p/210736#M42184</link>
    <description>&lt;P&gt;This code places the data table name into a JSL variable&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/cities.jmp" );

MY_NAME = dt &amp;lt;&amp;lt; get name;
Show( MY_NAME );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 27 May 2019 14:52:34 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2019-05-27T14:52:34Z</dc:date>
    <item>
      <title>How to store the current filename as entries in a new variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-store-the-current-filename-as-entries-in-a-new-variable/m-p/210726#M42183</link>
      <description>&lt;P&gt;Let's imagine we open cities.jmp.&lt;/P&gt;
&lt;P&gt;How could I get the name (pun intended) of 'cities' as entries for a new variable, say "MY_NAME".&lt;/P&gt;
&lt;P&gt;So, the variable-to-be "MY_NAME" contains multiple instances of 'cities'. By nature, it has to be character, and "MY_NAME" is not a variable, but a constant.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, any idea how do do this?&lt;/P&gt;
&lt;P&gt;I know there's a file function. GET NAME. But, I haven't made it so far to actually store the entries succesfully in MY_NAME.&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; still Newbie&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 13:07:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-store-the-current-filename-as-entries-in-a-new-variable/m-p/210726#M42183</guid>
      <dc:creator>Newbie2Jumpie</dc:creator>
      <dc:date>2019-05-28T13:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to story the current filename as entries in a new variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-store-the-current-filename-as-entries-in-a-new-variable/m-p/210736#M42184</link>
      <description>&lt;P&gt;This code places the data table name into a JSL variable&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/cities.jmp" );

MY_NAME = dt &amp;lt;&amp;lt; get name;
Show( MY_NAME );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 May 2019 14:52:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-store-the-current-filename-as-entries-in-a-new-variable/m-p/210736#M42184</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-05-27T14:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to story the current filename as entries in a new variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-store-the-current-filename-as-entries-in-a-new-variable/m-p/210739#M42185</link>
      <description>I'm not at work right now...&lt;BR /&gt;&lt;BR /&gt;That's all?&lt;BR /&gt;The new field MY_NAME will contain "cities" in every row?&lt;BR /&gt;&lt;BR /&gt;Can't wait to get back to work :)&lt;/img&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 27 May 2019 16:04:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-store-the-current-filename-as-entries-in-a-new-variable/m-p/210739#M42185</guid>
      <dc:creator>Newbie2Jumpie</dc:creator>
      <dc:date>2019-05-27T16:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to store the current filename as entries in a new variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-store-the-current-filename-as-entries-in-a-new-variable/m-p/210743#M42186</link>
      <description>&lt;P&gt;I think we've got a confusion of terms. In a JMP data table we call them &lt;EM&gt;columns&lt;/EM&gt;, not fields or variables (or constants). So, when you asked how to create a &lt;EM&gt;variable&lt;/EM&gt; with 'cities' it was assumed you meant a JSL variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, it seems you really want a column in your data table with the name of the data table in every row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You've already seen, thanks to&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;, that the &lt;A href="https://www.jmp.com/support/help/14-2/data-tables-3.shtml#1919171" target="_blank" rel="noopener"&gt;&amp;lt;&amp;lt;Get Name()&lt;/A&gt; message will give you the name of the data table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you need to create a new column in your data table using the &lt;A href="https://www.jmp.com/support/help/14-2/data-tables-3.shtml#1547374" target="_blank" rel="noopener"&gt;&amp;lt;&amp;lt;New Column()&lt;/A&gt; message. Within the New Column() you can use Set Values() to set the values for each row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, now we just need a list of values. We can get that using the &lt;A href="https://www.jmp.com/support/help/14-2/character-functions-2.shtml#2485888" target="_blank" rel="noopener"&gt;Repeat()&lt;/A&gt; function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The whole thing looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Cities.jmp" );

dtname = dt &amp;lt;&amp;lt; get name();

dtname_list = Repeat( {dtname}, N Row( dt ) );

dt &amp;lt;&amp;lt; New Column( "Data Table Name", character, set values( dtname_list ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are other ways of getting values into a column. We could use a formula where the "formula" is just a constant string but the syntax of that in JSL gets a bit confusing since we need to deal with when JSL expressions are evaluated (think Macro quoting in SAS; that's not where you'd want someone new to get started.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, having said all of that, there aren't many cases where you need the name of the data table in all the rows of the data table as JMP will create columns like this in the cases where they are handy. For example, when &lt;A href="https://www.jmp.com/support/help/14-2/concatenate-data-tables.shtml#192324" target="_blank" rel="noopener"&gt;concatenating data tables&lt;/A&gt;, there's an option to create a column with the name of the table that each row comes from.&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="JMPScreenSnapz010.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/17443iE6768197E28BFC2B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JMPScreenSnapz010.png" alt="JMPScreenSnapz010.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other table manipulations commands have similar options. So, perhaps you can tell us what you're trying to do that you feel you need this column and we may be able to help you even further.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 13:09:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-store-the-current-filename-as-entries-in-a-new-variable/m-p/210743#M42186</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2019-05-28T13:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to story the current filename as entries in a new variable</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-store-the-current-filename-as-entries-in-a-new-variable/m-p/210756#M42189</link>
      <description>&lt;P&gt;And to illustrate that in JMP there are typically many ways to approach ones solution, here is a variation on&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6878"&gt;@Jeff_Perkinson&lt;/a&gt; example&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Cities.jmp" );

dtname = dt &amp;lt;&amp;lt; get name();

dt &amp;lt;&amp;lt; New Column( "Data Table Name", character, set each value( dtname ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 May 2019 19:06:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-store-the-current-filename-as-entries-in-a-new-variable/m-p/210756#M42189</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-05-27T19:06:58Z</dc:date>
    </item>
  </channel>
</rss>

