<?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: Move files from file names in dataset. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Move-files-from-file-names-in-dataset/m-p/468056#M285392</link>
    <description>&lt;P&gt;Can you post example of test data of have - in the for of a dataset.&amp;nbsp; Then show what you want at the end.&amp;nbsp; I.e. do you want a text file with those names or a dataset - a macro list is not good - you can see that for all the extra code you have to provide.&amp;nbsp; Also please avoid coding all in shouting, it makes reading code very hard.&lt;/P&gt;
&lt;P&gt;It seems like you just want a stream of copy commands put out at the end, so maybe something like:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  length comm $2000;
  set new;
  comm=cat('%sysexec copy "\\nas\KDrive\EFAX\',strip(filename),'" "\\nas\ngh\forms - new");
  call execute(comm);
run;&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Jun 2018 13:59:53 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-06-06T13:59:53Z</dc:date>
    <item>
      <title>Move files from file names in dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-files-from-file-names-in-dataset/m-p/468049#M285391</link>
      <description>&lt;P&gt;Hello. I am trying to create a workflow that reads in a list of files from a system folder, filters the list based on a few other tables, and then provides a list of files that should be moved to another folder.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble with the last part of this workflow. The dataset that results from the filter contains a single column named FileName which contains files needing to be moved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(&lt;STRONG&gt;filename example&lt;/STRONG&gt;: Last, First EmployeeID.TIF)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I’ve tried a few solutions like creating a macro scan loop and calling an x command, but each solution I come up with either crashes or fails to move all/any of the files. Any help with this would be great. Here is my latest iteration that tends to just make SAS crash.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
   CREATE TABLE WORK.UNIQ_NEW AS 
   SELECT DISTINCT 
      CATT('"\\nas\KDrive\EFAX\',t1.FileName,'"') AS FileName
      FROM WORK.New t1
      ORDER BY t1.FileName;
QUIT;

/* Macro to SCAN through DATALOG */
%MACRO SCANLOOP(SCANFILE,FIELD1);
    %LET actioncmd = copy;
	%LET destination = "\\nas\\NGH\Forms - New";
	%LET separator_s =%str( );

	DATA _NULL_;
		IF 0 THEN SET &amp;amp;SCANFILE NOBS=X;
		CALL SYMPUT('RECCOUNT',X);
		STOP;
	RUN;

	%DO I=1 %TO &amp;amp;RECCOUNT;

		DATA _NULL_;
			SET &amp;amp;SCANFILE (FIRSTOBS=&amp;amp;I);
			CALL SYMPUT('VAR1',&amp;amp;FIELD1);
			STOP;
		RUN;

		%LET command = %sysfunc(catx(&amp;amp;separator_s,&amp;amp;actioncmd,&amp;amp;VAR1,&amp;amp;destination));
		x &amp;amp;command;

	%END;
%MEND SCANLOOP;
/* Call SCANLOOP */
%SCANLOOP(WORK.UNIQ_NEW,FileName);
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Jun 2018 13:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-files-from-file-names-in-dataset/m-p/468049#M285391</guid>
      <dc:creator>NGHAnalyst</dc:creator>
      <dc:date>2018-06-06T13:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Move files from file names in dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-files-from-file-names-in-dataset/m-p/468056#M285392</link>
      <description>&lt;P&gt;Can you post example of test data of have - in the for of a dataset.&amp;nbsp; Then show what you want at the end.&amp;nbsp; I.e. do you want a text file with those names or a dataset - a macro list is not good - you can see that for all the extra code you have to provide.&amp;nbsp; Also please avoid coding all in shouting, it makes reading code very hard.&lt;/P&gt;
&lt;P&gt;It seems like you just want a stream of copy commands put out at the end, so maybe something like:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  length comm $2000;
  set new;
  comm=cat('%sysexec copy "\\nas\KDrive\EFAX\',strip(filename),'" "\\nas\ngh\forms - new");
  call execute(comm);
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Jun 2018 13:59:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-files-from-file-names-in-dataset/m-p/468056#M285392</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-06T13:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Move files from file names in dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-files-from-file-names-in-dataset/m-p/468077#M285393</link>
      <description>&lt;P&gt;Thank you so much for your help and advise! That worked perfectly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 14:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-files-from-file-names-in-dataset/m-p/468077#M285393</guid>
      <dc:creator>NGHAnalyst</dc:creator>
      <dc:date>2018-06-06T14:50:34Z</dc:date>
    </item>
  </channel>
</rss>

