<?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: File name change in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782781#M249551</link>
    <description>&lt;P&gt;Please post the whole log of the data step in a code box (&amp;lt;/&amp;gt; button).&lt;/P&gt;</description>
    <pubDate>Sun, 28 Nov 2021 17:55:54 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-11-28T17:55:54Z</dc:date>
    <item>
      <title>File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782395#M249404</link>
      <description>I have 2 csv files in c:\ drive.&lt;BR /&gt;How can I change file names by swapping each one without uploading/importing into sas?&lt;BR /&gt;I have: test.csv and test1.csv&lt;BR /&gt;&lt;BR /&gt;I want to change test.csv to test1.csv&lt;BR /&gt;And test1.csv to test.csv&lt;BR /&gt;&lt;BR /&gt;Thank you.</description>
      <pubDate>Thu, 25 Nov 2021 06:56:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782395#M249404</guid>
      <dc:creator>Emma2021</dc:creator>
      <dc:date>2021-11-25T06:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782396#M249405</link>
      <description>&lt;P&gt;For example, you could try using a different file name once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options noxwait xsync;
x 'rename C:\Temp\test.csv text0.csv';
x 'rename C:\Temp\test1.csv text.csv';
x 'rename C:\Temp\test0.csv text1.csv';
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Nov 2021 07:05:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782396#M249405</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-11-25T07:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782397#M249406</link>
      <description>&lt;P&gt;If this has to be done in a sas session, using the &lt;A href="https://documentation.sas.com/doc/de/pgmsascdc/9.4_3.4/lefunctionsref/p14axci3mo3egan1okbcydvbt433.htm" target="_self"&gt;rename&lt;/A&gt; function in a data step seems to be the best choice. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 07:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782397#M249406</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-11-25T07:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782403#M249412</link>
      <description>&lt;P&gt;[Deleted]&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;'s reply is better.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 07:19:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782403#M249412</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-25T07:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782407#M249414</link>
      <description>&lt;P&gt;If your SAS runs on a remote server, you (most probably) cannot do this from SAS code. You would need to share your C: drive to the network and mount it on the SAS server.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 07:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782407#M249414</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-25T07:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782446#M249432</link>
      <description>My sas is on my local not server based</description>
      <pubDate>Thu, 25 Nov 2021 14:49:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782446#M249432</guid>
      <dc:creator>Emma2021</dc:creator>
      <dc:date>2021-11-25T14:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782447#M249433</link>
      <description>Thank you, but it does not do anything. Should I add a line of code perhaps “run;”?&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Nov 2021 14:50:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782447#M249433</guid>
      <dc:creator>Emma2021</dc:creator>
      <dc:date>2021-11-25T14:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782450#M249436</link>
      <description>I would not recommend X command statements - they will work on your computer but not necessarily any system. &lt;BR /&gt;Using the RENAME function will work in any OS making your code more portable. Note that if you're swapping names, you'll need a temporary name for one of them to avoid conflicts. &lt;BR /&gt;The usage is the same as with FCOPY/FINFO from your previous question.&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Nov 2021 15:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782450#M249436</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-25T15:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782455#M249438</link>
      <description>&lt;P&gt;The problem with the X statement is that it does not really tell you what happened. Use PIPE to retrieve the responses of the command:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data commands;
input command $80.; /* safe because DATALINES are always padded to at least 80 characters */
datalines;
rename C:\Temp\test.csv text0.csv
rename C:\Temp\test1.csv text.csv
rename C:\Temp\test0.csv text1.csv
;

data _null_;
set commands;
command = catx(" ",command,'2&amp;gt;&amp;amp;1'); /* reroutes stderr to stdout, so everything is caught */
infile dummy pipe filevar=command eof=done;
start:
  input;
  put _infile_;
  go to start;
done:
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested, as On Demand runs with NOXCMD.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 17:16:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782455#M249438</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-25T17:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782777#M249549</link>
      <description>Thanks, but it does not do anything either.</description>
      <pubDate>Sun, 28 Nov 2021 17:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782777#M249549</guid>
      <dc:creator>Emma2021</dc:creator>
      <dc:date>2021-11-28T17:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782780#M249550</link>
      <description>&lt;P&gt;Try using the RENAME() function.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Create two files ;
data _null_;
  file 'c:\downloads\file1.csv' ;
  put 'file1';
  file 'c:\downloads\file2.csv' ;
  put 'file2';
run;

* Use the RENAME() function to "swap" them ;
data _null_;
  if fileexist('c:\downloads\temp') then put 'Will not work because temp file already exists';
  else do;
    rc1=rename('c:\downloads\file1.csv','c:\downloads\temp','file');
    rc2=rename('c:\downloads\file2.csv','c:\downloads\file1.csv','file');
    rc3=rename('c:\downloads\temp','c:\downloads\file2.csv','file');
    put (rc1-rc3)(=);
  end;
run;

* check that it worked ;
data _null_;
  infile 'c:\downloads\file1.csv' ;
  input;
  put _infile_;
  infile 'c:\downloads\file2.csv' ;
  input;
  put _infile_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Nov 2021 17:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782780#M249550</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-28T17:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782781#M249551</link>
      <description>&lt;P&gt;Please post the whole log of the data step in a code box (&amp;lt;/&amp;gt; button).&lt;/P&gt;</description>
      <pubDate>Sun, 28 Nov 2021 17:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782781#M249551</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-28T17:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782867#M249572</link>
      <description>I would not recommend X command statements - they will work on your computer but not necessarily any system.&lt;BR /&gt;</description>
      <pubDate>Mon, 29 Nov 2021 10:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782867#M249572</guid>
      <dc:creator>starrtiktokk</dc:creator>
      <dc:date>2021-11-29T10:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: File name change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782882#M249579</link>
      <description>&lt;P&gt;Maxim 14 says "Use the Right Tool".&lt;/P&gt;
&lt;P&gt;When you can do a complex action with a one line system command instead of 100 lines of SAS code (and much quicker at that!), there is no question which is the better option.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 11:53:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/File-name-change/m-p/782882#M249579</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-29T11:53:17Z</dc:date>
    </item>
  </channel>
</rss>

