<?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 to save a file with name as a variable in For loop to save multiple files in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-save-a-file-with-name-as-a-variable-in-For-loop-to-save/m-p/292965#M55623</link>
    <description>&lt;P&gt;Hi, I am trying to save files in a for loop, the problem is how to put a variable into the file saving procedure,&lt;/P&gt;
&lt;P&gt;However, it looks the file save part is not working.&lt;/P&gt;
&lt;P&gt;I didn't use any clear global to make sure&amp;nbsp;filename has be assigned with the original value.&lt;/P&gt;
&lt;P&gt;Is there any problem with my saving part?&lt;/P&gt;
&lt;P&gt;Thanks&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;// filename is a variable assigned below,
For( j = 1, j &amp;lt;= N Row( sdt ), j++,
filename = Column( sdt, "file" )[j];
Close( Data Table( sdt ), No Save );

// During saving the file, the directory is fixed, however the filename is an variable, &lt;BR /&gt;// the goal is to use the left(filename,18) and concatenate with "_Type1" in the file name.

dt1 = Current Data Table();
dt1 &amp;lt;&amp;lt; save( "C:\Users\file\JSL\"||Right( filename,18)||"_Type1.csv" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 23:36:13 GMT</pubDate>
    <dc:creator>Stokes</dc:creator>
    <dc:date>2023-06-09T23:36:13Z</dc:date>
    <item>
      <title>How to save a file with name as a variable in For loop to save multiple files</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-save-a-file-with-name-as-a-variable-in-For-loop-to-save/m-p/292965#M55623</link>
      <description>&lt;P&gt;Hi, I am trying to save files in a for loop, the problem is how to put a variable into the file saving procedure,&lt;/P&gt;
&lt;P&gt;However, it looks the file save part is not working.&lt;/P&gt;
&lt;P&gt;I didn't use any clear global to make sure&amp;nbsp;filename has be assigned with the original value.&lt;/P&gt;
&lt;P&gt;Is there any problem with my saving part?&lt;/P&gt;
&lt;P&gt;Thanks&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;// filename is a variable assigned below,
For( j = 1, j &amp;lt;= N Row( sdt ), j++,
filename = Column( sdt, "file" )[j];
Close( Data Table( sdt ), No Save );

// During saving the file, the directory is fixed, however the filename is an variable, &lt;BR /&gt;// the goal is to use the left(filename,18) and concatenate with "_Type1" in the file name.

dt1 = Current Data Table();
dt1 &amp;lt;&amp;lt; save( "C:\Users\file\JSL\"||Right( filename,18)||"_Type1.csv" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:36:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-save-a-file-with-name-as-a-variable-in-For-loop-to-save/m-p/292965#M55623</guid>
      <dc:creator>Stokes</dc:creator>
      <dc:date>2023-06-09T23:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a file with name as a variable in For loop to save multiple files</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-save-a-file-with-name-as-a-variable-in-For-loop-to-save/m-p/293270#M55627</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I chanched the code a bit so this may help:&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" );

path = "C:\Users\file\JSL\"


For( j = 1, j &amp;lt;= N Row( dt ), j++,
	dt &amp;lt;&amp;lt; save as (path || dt:name[j] || "_Type1.csv" );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It can be that you need to do a&amp;nbsp; "save as" to make it work.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 05:57:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-save-a-file-with-name-as-a-variable-in-For-loop-to-save/m-p/293270#M55627</guid>
      <dc:creator>Mauro_Gerber</dc:creator>
      <dc:date>2020-08-28T05:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a file with name as a variable in For loop to save multiple files</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-save-a-file-with-name-as-a-variable-in-For-loop-to-save/m-p/294034#M55669</link>
      <description>&lt;P&gt;Hi, Thanks a lot.&lt;/P&gt;&lt;P&gt;It works now.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 23:29:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-save-a-file-with-name-as-a-variable-in-For-loop-to-save/m-p/294034#M55669</guid>
      <dc:creator>Stokes</dc:creator>
      <dc:date>2020-08-28T23:29:38Z</dc:date>
    </item>
  </channel>
</rss>

