<?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: How to copy a file with the name stored in a data column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-file-with-the-name-stored-in-a-data-column/m-p/868007#M342832</link>
    <description>&lt;P&gt;It works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much! I think I wasn't able to see the missing instructions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I put the right code here in case someone is interested in :&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt; data _null_;
 set "&amp;lt;name_of_dataset&amp;gt;";
    length source destin $8;

	  retain indir "&amp;lt;source-folder&amp;gt;" outdir "&amp;lt;destin-folder&amp;gt;";

    if fileexist (indir || '/' || image_name) then do;
      rc = filename (source, indir || '/' || image_name);
      rc = filename (destin, outdir || '/' || image_name);
      rc = fcopy (source, destin);
      if rc ne 0 then do;
        msg = sysmsg();
        putlog msg;
      end;
      rc = filename (source); call missing (source);
      rc = filename (destin); call missing (destin);
    end;

  run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 Apr 2023 15:23:07 GMT</pubDate>
    <dc:creator>mmoriss</dc:creator>
    <dc:date>2023-04-04T15:23:07Z</dc:date>
    <item>
      <title>How to copy a file with the name stored in a data column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-file-with-the-name-stored-in-a-data-column/m-p/867993#M342825</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using SAS base 9.4.&lt;/P&gt;&lt;P&gt;In my library named "source", I have a dataset called "X_test".&lt;/P&gt;&lt;P&gt;In this dataset, there is a column called "image_name" which contains the names of an image stored in my folder.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mmoriss_0-1680618625774.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82317i80861183C053DA5C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mmoriss_0-1680618625774.png" alt="mmoriss_0-1680618625774.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to write a macro that for each "image_name", go to a source folder, select the image and copy it into an other folder.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here the code I wrote but I don't know how to said to look in each column to get the file name.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The error is that SAS doesn't have the image_name. I got "File incorrect" because image_name=. for SAS.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Anyone have a solution to suggest me ?&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;data _null_;
    length source destin $8;

    retain indir "C:/Users/Me/image_test_sas" outdir "C:/Users/Me/image_copy";
    
    if fileexist (indir || '/' || image_name) then do;
      rc = filename (source, indir || '/' || image_name);
      rc = filename (destin, outdir || '/' || image_name);
      rc = fcopy (source, destin);
      if rc ne 0 then do;
        msg = sysmsg();
        putlog msg;
      end;
      rc = filename (source); call missing (source);
      rc = filename (destin); call missing (destin);
    end;
  run;&lt;/PRE&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 14:55:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-file-with-the-name-stored-in-a-data-column/m-p/867993#M342825</guid>
      <dc:creator>mmoriss</dc:creator>
      <dc:date>2023-04-04T14:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy a file with the name stored in a data column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-file-with-the-name-stored-in-a-data-column/m-p/867996#M342826</link>
      <description>&lt;P&gt;What is wrong with the code you are showing? Are there errors in the log? If so, show us the ENTIRE log for this data step (every single line, every single character, with nothing omitted or removed).&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 14:41:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-file-with-the-name-stored-in-a-data-column/m-p/867996#M342826</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-04T14:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy a file with the name stored in a data column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-file-with-the-name-stored-in-a-data-column/m-p/868000#M342828</link>
      <description>&lt;P&gt;Ok, I've upadated my post.&lt;/P&gt;&lt;P&gt;I didn't run my code because I know that it is incomplete.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know how to select image_name for each line of my dataset inside my code.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 14:57:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-file-with-the-name-stored-in-a-data-column/m-p/868000#M342828</guid>
      <dc:creator>mmoriss</dc:creator>
      <dc:date>2023-04-04T14:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy a file with the name stored in a data column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-file-with-the-name-stored-in-a-data-column/m-p/868002#M342830</link>
      <description>&lt;P&gt;I think you are missing a SET statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    set malib.x_test2;
    ...
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Apr 2023 15:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-file-with-the-name-stored-in-a-data-column/m-p/868002#M342830</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-04T15:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy a file with the name stored in a data column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-file-with-the-name-stored-in-a-data-column/m-p/868007#M342832</link>
      <description>&lt;P&gt;It works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much! I think I wasn't able to see the missing instructions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I put the right code here in case someone is interested in :&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt; data _null_;
 set "&amp;lt;name_of_dataset&amp;gt;";
    length source destin $8;

	  retain indir "&amp;lt;source-folder&amp;gt;" outdir "&amp;lt;destin-folder&amp;gt;";

    if fileexist (indir || '/' || image_name) then do;
      rc = filename (source, indir || '/' || image_name);
      rc = filename (destin, outdir || '/' || image_name);
      rc = fcopy (source, destin);
      if rc ne 0 then do;
        msg = sysmsg();
        putlog msg;
      end;
      rc = filename (source); call missing (source);
      rc = filename (destin); call missing (destin);
    end;

  run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Apr 2023 15:23:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-copy-a-file-with-the-name-stored-in-a-data-column/m-p/868007#M342832</guid>
      <dc:creator>mmoriss</dc:creator>
      <dc:date>2023-04-04T15:23:07Z</dc:date>
    </item>
  </channel>
</rss>

