<?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: Moving files after output is successfully generated in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38376#M7693</link>
    <description>So, instead of a macro variable, use instream data-strings with your explicit commands to invoke - it's easier than all that CALL SYSTEM('&lt;YOUR_COMMAND&gt;");  logic, I'd say.&lt;BR /&gt;
&lt;BR /&gt;
There are other techniques but this one is straightforward and easily supported.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/YOUR_COMMAND&gt;</description>
    <pubDate>Thu, 28 May 2009 21:15:23 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-05-28T21:15:23Z</dc:date>
    <item>
      <title>Moving files after output is successfully generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38368#M7685</link>
      <description>HI,&lt;BR /&gt;
&lt;BR /&gt;
Please let me know if there is an alternative simpler way of moving the all the files n folders to another folder.&lt;BR /&gt;
&lt;BR /&gt;
Below is my SAS code:&lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_;&lt;BR /&gt;
	call symput("path","/pgm/intel");&lt;BR /&gt;
	call symput("roll_ind", "Y");&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%put "PATH: " &amp;amp;path.;&lt;BR /&gt;
%put "Roll indicator: " &amp;amp;roll_ind.;&lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_;&lt;BR /&gt;
	 if "&amp;amp;roll_ind." = "Y" then do;&lt;BR /&gt;
		/* delete the prev folder */&lt;BR /&gt;
		call system ("rm -r &amp;amp;path./prev") ;&lt;BR /&gt;
		&lt;BR /&gt;
		/* move the last weeks data to previous */&lt;BR /&gt;
		call system ("mv &amp;amp;path./curr &amp;amp;path./prev") ;&lt;BR /&gt;
&lt;BR /&gt;
		/* move this weeks data to current */&lt;BR /&gt;
		call system ("mv &amp;amp;path./r_out &amp;amp;path./curr") ;&lt;BR /&gt;
		call system ("mv &amp;amp;path./csampl/output &amp;amp;path./curr/csampl") ;&lt;BR /&gt;
		call system ("mv &amp;amp;path./pipe &amp;amp;path./curr") ;&lt;BR /&gt;
&lt;BR /&gt;
		/* Setting the appropriate permissions to the files in current */&lt;BR /&gt;
		call system ("cd &amp;amp;path./curr") ;&lt;BR /&gt;
		call system ("chmod -R 755 *.sas7bdat");&lt;BR /&gt;
		call system ("chmod -R 755 *.gz");&lt;BR /&gt;
		call system ("chmod -R 755 *.zip");&lt;BR /&gt;
&lt;BR /&gt;
		/* Creating the directories for the processing the data next week */&lt;BR /&gt;
		***  ***;&lt;BR /&gt;
		call system ("mkdir &amp;amp;path./r_out") ;&lt;BR /&gt;
		call system ("cd &amp;amp;path./r_out") ;&lt;BR /&gt;
		call system ("chmod -R 755 ");&lt;BR /&gt;
&lt;BR /&gt;
		call system ("mkdir &amp;amp;path./r_out/process1") ;&lt;BR /&gt;
		call system ("cd &amp;amp;path./r_out/process1") ;&lt;BR /&gt;
		call system ("chmod -R 755 ");&lt;BR /&gt;
&lt;BR /&gt;
		call system ("mkdir &amp;amp;path./r_out/process1/Temp") ;&lt;BR /&gt;
		call system ("cd &amp;amp;path./r_out/process1/Temp") ;&lt;BR /&gt;
		call system ("chmod -R 755 ");&lt;BR /&gt;
&lt;BR /&gt;
		***  ***;&lt;BR /&gt;
		call system ("mkdir &amp;amp;path./csampl") ;&lt;BR /&gt;
		call system ("cd &amp;amp;path./csampl") ;&lt;BR /&gt;
		call system ("chmod -R 755 ");&lt;BR /&gt;
&lt;BR /&gt;
		***  ***;&lt;BR /&gt;
		call system ("mkdir &amp;amp;path./pipe") ;&lt;BR /&gt;
		call system ("cd &amp;amp;path./pipe") ;&lt;BR /&gt;
		call system ("chmod -R 755 ");&lt;BR /&gt;
&lt;BR /&gt;
	 	put "******************************************************************************";&lt;BR /&gt;
		put "MESSAGE: Data is ROLLED into current and previous folders";&lt;BR /&gt;
	 	put "******************************************************************************";&lt;BR /&gt;
&lt;BR /&gt;
	 end;&lt;BR /&gt;
	 else do;&lt;BR /&gt;
	 	put "******************************************************************************";&lt;BR /&gt;
		put "MESSAGE: Data is NOT Rolled into current and previous folders";&lt;BR /&gt;
	 	put "******************************************************************************";&lt;BR /&gt;
	 end;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
RB</description>
      <pubDate>Thu, 28 May 2009 17:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38368#M7685</guid>
      <dc:creator>rsb7678</dc:creator>
      <dc:date>2009-05-28T17:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Moving files after output is successfully generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38369#M7686</link>
      <description>what operating system are you using?</description>
      <pubDate>Thu, 28 May 2009 18:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38369#M7686</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-28T18:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Moving files after output is successfully generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38370#M7687</link>
      <description>SAS provides DATA step functions, which also can be invoked using %SYSFUNC from macro language.  I believe you would have better success and can interrogate / respond to specific environment conditions (likely regardless of OS) if you use this approach.  Search the SAS support  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website for SAS-hosted documentation (including "companion" documentation for various OS environments) and also supplemental technical / conference papers on this type of topic.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 28 May 2009 19:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38370#M7687</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-05-28T19:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Moving files after output is successfully generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38371#M7688</link>
      <description>I'm using UNIX AIX 5.3 platform.</description>
      <pubDate>Thu, 28 May 2009 19:32:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38371#M7688</guid>
      <dc:creator>rsb7678</dc:creator>
      <dc:date>2009-05-28T19:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Moving files after output is successfully generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38372#M7689</link>
      <description>At a minimum, consider reducing the amount of SAS code, by converting your series of CALL EXECUTE commands to a DATA step with a DO / END loop, and having DATALINES;  coded with your series of commands imbedded instream ; read up the input with an INPUT statement in your DATA step.  And to substitute your "variable information", use a special character string like $mydir$ which you would reference in a SAS assignment statement, as shown below:&lt;BR /&gt;
&lt;BR /&gt;
%let _mydir_ = /yada/yada/yada;&lt;BR /&gt;
DATA _NULL_;&lt;BR /&gt;
INFILE DATALINES TRUNCOVER;&lt;BR /&gt;
LENGTH COMMAND $200;&lt;BR /&gt;
INPUT COMMAND $CHAR200. ;&lt;BR /&gt;
COMMAND = TRANWRD(COMMAND,'_mydir_',"&amp;amp;_mydir_");&lt;BR /&gt;
* UNCOMMENT LINE BELOW WHEN READY TO GO. ;&lt;BR /&gt;
* CALL SYSTEM(COMMAND);&lt;BR /&gt;
PUTLOG '&amp;gt;ECHO_COMMAND&amp;gt;  ' COMMAND;&lt;BR /&gt;
DATALINES;&lt;BR /&gt;
rm _mydir_&lt;BR /&gt;
mkdir _mydir_&lt;BR /&gt;
...whatever other commands needed...&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 28 May 2009 19:34:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38372#M7689</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-05-28T19:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Moving files after output is successfully generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38373#M7690</link>
      <description>Thanks Scott.&lt;BR /&gt;
This works out.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Radhika</description>
      <pubDate>Thu, 28 May 2009 20:15:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38373#M7690</guid>
      <dc:creator>rsb7678</dc:creator>
      <dc:date>2009-05-28T20:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Moving files after output is successfully generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38374#M7691</link>
      <description>Hi Scott,&lt;BR /&gt;
A quick question , why are you using tranwrd function and the macro variable _mydir_ ?&lt;BR /&gt;
Each step is a different command with a different directory path.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
RB</description>
      <pubDate>Thu, 28 May 2009 20:46:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38374#M7691</guid>
      <dc:creator>rsb7678</dc:creator>
      <dc:date>2009-05-28T20:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: Moving files after output is successfully generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38375#M7692</link>
      <description>Sounds like a static macro variable (substitution) approach will not work - the TRANWRD function translates the word (sorry, could not help myself!) found in "argument2" to the word found in "argument3".&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
SAS 9.2 DOC reference - TRANWRD Function:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000215027.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000215027.htm&lt;/A&gt;</description>
      <pubDate>Thu, 28 May 2009 21:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38375#M7692</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-05-28T21:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Moving files after output is successfully generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38376#M7693</link>
      <description>So, instead of a macro variable, use instream data-strings with your explicit commands to invoke - it's easier than all that CALL SYSTEM('&lt;YOUR_COMMAND&gt;");  logic, I'd say.&lt;BR /&gt;
&lt;BR /&gt;
There are other techniques but this one is straightforward and easily supported.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/YOUR_COMMAND&gt;</description>
      <pubDate>Thu, 28 May 2009 21:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Moving-files-after-output-is-successfully-generated/m-p/38376#M7693</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-05-28T21:15:23Z</dc:date>
    </item>
  </channel>
</rss>

