<?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: SFTP with current date in filename in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475374#M30836</link>
    <description>&lt;P&gt;You need to put double quotes around macro variables to get them to resolve:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;filename&lt;/SPAN&gt; outfile1 sftp "&lt;SPAN class="token string"&gt;/c:/dummy/&amp;amp;date.file_trial1.csv"&lt;/SPAN&gt; USER&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"dummy_123"&lt;/SPAN&gt; host&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"821.12....&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could also simplfy by removing the &amp;amp;date macro variable and using a function:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;filename&lt;/SPAN&gt; outfile1 sftp "&lt;SPAN class="token string"&gt;/c:/dummy/%sysfunc(date(),date9.)_file_trial1.csv"&lt;/SPAN&gt; USER&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"dummy_123"&lt;/SPAN&gt; host&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"821.12....&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;However, I recommend not putting data in filenames, data should go in the data area as this makes further processing far simpler, and doesn't break version control systems and such like.&amp;nbsp; For instance, we refuse to accept dated, version number&amp;nbsp; or any such thing in files, they should all have the same name so the version control system can keep the history, and out users do not need to code for this.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jul 2018 08:44:29 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-07-04T08:44:29Z</dc:date>
    <item>
      <title>SFTP with current date in filename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475373#M30835</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data trial;
input filename $ number $;
datalines;
testtest 999
;&lt;BR /&gt;run;

/*code 1*/

%ds2csv(data=trial, colhead=N, runmode=b, csvfile=D:\testing2\&amp;amp;date.file_trial1.csv);


/*code 2*/

filename outfile1 sftp '/c:/dummy/&amp;amp;date.file_trial1.csv' USER="dummy_123" host="821.12.23.321" optionsx= "-i d:\dummy_key.ppk -pw testing000" DEBUG;
PROC EXPORT Data = test trial= outfile1 DBMS=csv REPLACE;run;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would require help in this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my code works for code 1, which means the file saved in my d drive is 180704.file_trial1.csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;while the file saved for code 2 is&amp;nbsp;&amp;amp;date.file_trial1.csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would kindly seek assistance on how to pass current date over to that file that requires to be sftp over.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jul 2018 08:24:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475373#M30835</guid>
      <dc:creator>brighterlight</dc:creator>
      <dc:date>2018-07-04T08:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP with current date in filename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475374#M30836</link>
      <description>&lt;P&gt;You need to put double quotes around macro variables to get them to resolve:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;filename&lt;/SPAN&gt; outfile1 sftp "&lt;SPAN class="token string"&gt;/c:/dummy/&amp;amp;date.file_trial1.csv"&lt;/SPAN&gt; USER&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"dummy_123"&lt;/SPAN&gt; host&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"821.12....&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could also simplfy by removing the &amp;amp;date macro variable and using a function:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;filename&lt;/SPAN&gt; outfile1 sftp "&lt;SPAN class="token string"&gt;/c:/dummy/%sysfunc(date(),date9.)_file_trial1.csv"&lt;/SPAN&gt; USER&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"dummy_123"&lt;/SPAN&gt; host&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"821.12....&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;However, I recommend not putting data in filenames, data should go in the data area as this makes further processing far simpler, and doesn't break version control systems and such like.&amp;nbsp; For instance, we refuse to accept dated, version number&amp;nbsp; or any such thing in files, they should all have the same name so the version control system can keep the history, and out users do not need to code for this.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jul 2018 08:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475374#M30836</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-07-04T08:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP with current date in filename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475390#M30837</link>
      <description>&lt;P&gt;Hi thanks for the reply. Unfortunately, I have tried it before as well, it doesn't work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jul 2018 10:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475390#M30837</guid>
      <dc:creator>brighterlight</dc:creator>
      <dc:date>2018-07-04T10:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP with current date in filename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475391#M30838</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;it doesn't work" - this does not tell us anything.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jul 2018 10:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475391#M30838</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-07-04T10:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP with current date in filename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475509#M30841</link>
      <description>&lt;P&gt;The file that was SFTP over was&amp;nbsp;%sysfunc(date(),date9.)_file_trial1.csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There wasn't any error so there's nothing much I can mention about it.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 01:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475509#M30841</guid>
      <dc:creator>brighterlight</dc:creator>
      <dc:date>2018-07-05T01:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP with current date in filename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475538#M30842</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;I think it is easier to create the file name in a data step first. In that way you can check everything before defining the filename.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data createdFilename;
date = put(date(),date9.);
filename = cats(date,'_file_trial1.csv');
call symput('_fn',filename);
run;

%put &amp;amp;_fn;

filename outfile1 sftp "&amp;amp;_fn" USER="dummy_123" host="821.12.23.321" optionsx= "-i d:\dummy_key.ppk -pw testing000" DEBUG;
PROC EXPORT Data = test trial= outfile1 DBMS=csv REPLACE;run;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;//Fredrik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 07:40:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475538#M30842</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2018-07-05T07:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP with current date in filename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475549#M30843</link>
      <description>&lt;P&gt;Hi Fredrik,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks but this will not work either because a location is need, the statement which you have after sftp excludes the location and I need the file name as well.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 08:56:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475549#M30843</guid>
      <dc:creator>brighterlight</dc:creator>
      <dc:date>2018-07-05T08:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP with current date in filename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475579#M30845</link>
      <description>&lt;P&gt;uhum, ok, but then you just add it to the _fn variable in the datastep or what?&lt;/P&gt;
&lt;P&gt;The thing with the macro variable is that it can contain anything you need, passwords, paths, options and so on,...:)&lt;/P&gt;
&lt;P&gt;//Fredrik&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 11:12:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SFTP-with-current-date-in-filename/m-p/475579#M30845</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2018-07-05T11:12:19Z</dc:date>
    </item>
  </channel>
</rss>

