<?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: Proc copy of a few datasets, here the list of datasets is mentioned in another dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797906#M313716</link>
    <description>Ah!! Writing it this way in the above post helped! I kept ready it incorrectly, my bad! Apologies. Just spent a lot of time reading it as--- &lt;BR /&gt;select "||dataset||" . Thank you!!</description>
    <pubDate>Tue, 22 Feb 2022 22:18:35 GMT</pubDate>
    <dc:creator>Tommer</dc:creator>
    <dc:date>2022-02-22T22:18:35Z</dc:date>
    <item>
      <title>Proc copy of a few datasets, here the list of datasets is mentioned in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797900#M313710</link>
      <description>&lt;P&gt;&lt;BR /&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a dataset ds22 which lists the datasets that need to be copied over:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data ds22;&lt;BR /&gt;dataset="DM";&lt;BR /&gt;output;&lt;BR /&gt;dataset="SC";&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The syntax used to copy them from f_ to o_ is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data chk_;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set ds22;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;call execute("proc copy in= f_ out=o_; select "||compress(dataset)||"; run;");&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone help me understand how ||compress(dataset)|| works here to read&amp;nbsp;the datasets called in ds22 individually?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Feb 2022 21:30:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797900#M313710</guid>
      <dc:creator>Tommer</dc:creator>
      <dc:date>2022-02-22T21:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc copy of a few datasets, here the list of datasets is mentioned in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797902#M313712</link>
      <description>&lt;P&gt;It's calling PROC COPY for each data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change the code slightly to see the generated code more easily by adding a variable (STR) to hold the code.&lt;/P&gt;
&lt;P&gt;Then view this CHK_ data set to see the code generated (note that I commented out the CALL EXECUTE so it won't run it in this one.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CALL EXECUTE simply executes code snippets passed to it. The data step builds that statement dynamically using the "dataset" variable in the ds22 dataset.&amp;nbsp;&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;PRE&gt;&lt;CODE class=" language-sas"&gt;data chk_;
   set ds22;
   str = ""proc copy in= f_ out=o_; select "||compress(dataset)||"; run;";
   *call execute(str);
run;

proc print data=chk_ (obs=5);
var str;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284458"&gt;@Tommer&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a dataset ds22 which lists the datasets that need to be copied over:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data ds22;&lt;BR /&gt;dataset="DM";&lt;BR /&gt;output;&lt;BR /&gt;dataset="SC";&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The syntax used to copy them from f_ to o_ is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data chk_;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set ds22;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;call execute("proc copy in= f_ out=o_; select "||compress(dataset)||"; run;");&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone help me understand how ||compress(dataset)|| works here to read&amp;nbsp;the datasets called in ds22 individually?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Feb 2022 21:43:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797902#M313712</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-22T21:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Proc copy of a few datasets, here the list of datasets is mentioned in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797903#M313713</link>
      <description>Thank you Reeza!&lt;BR /&gt;&lt;BR /&gt;I could not find any documentation on what --- select "||compress(dataset)||" does or how it works. I am only aware of pipe character for concatenation. Would you be able to provide any more info on how "||compress(dataset)||" reads as DM; SC etc?</description>
      <pubDate>Tue, 22 Feb 2022 21:56:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797903#M313713</guid>
      <dc:creator>Tommer</dc:creator>
      <dc:date>2022-02-22T21:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc copy of a few datasets, here the list of datasets is mentioned in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797904#M313714</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284458"&gt;@Tommer&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you Reeza!&lt;BR /&gt;&lt;BR /&gt;I could not find any documentation on what --- select "||compress(dataset)||" does or how it works. I am only aware of pipe character for concatenation. Would you be able to provide any more info on how "||compress(dataset)||" reads as DM; SC etc?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't understand why that is the part that is confusing.&amp;nbsp; Those &lt;STRONG&gt;are&lt;/STRONG&gt; concatenation operators.&amp;nbsp; The code is just placing the name of the dataset taken from the dataset variable DATASET in between two text strings.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps adding more white space will make it clearer?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; call execute(
  "proc copy in= f_ out=o_; select "
|| compress(dataset)
|| "; run;"
   );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It is the CALL EXECUTION() function call that actually turns the resulting string into executed SAS code.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Feb 2022 22:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797904#M313714</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-22T22:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc copy of a few datasets, here the list of datasets is mentioned in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797906#M313716</link>
      <description>Ah!! Writing it this way in the above post helped! I kept ready it incorrectly, my bad! Apologies. Just spent a lot of time reading it as--- &lt;BR /&gt;select "||dataset||" . Thank you!!</description>
      <pubDate>Tue, 22 Feb 2022 22:18:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797906#M313716</guid>
      <dc:creator>Tommer</dc:creator>
      <dc:date>2022-02-22T22:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc copy of a few datasets, here the list of datasets is mentioned in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797907#M313717</link>
      <description>Please ignore this, I was reading the code incorrectly.</description>
      <pubDate>Tue, 22 Feb 2022 22:20:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797907#M313717</guid>
      <dc:creator>Tommer</dc:creator>
      <dc:date>2022-02-22T22:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc copy of a few datasets, here the list of datasets is mentioned in another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797945#M313734</link>
      <description>&lt;P&gt;Since SELECT in PROC COPY accepts a list of dataset, you are better off doing it like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select dataset into :dsnames separated by " "
from ds22;
quit;

proc copy
  in= f_
  out=o_
;
select &amp;amp;dsnames.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Feb 2022 06:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-copy-of-a-few-datasets-here-the-list-of-datasets-is/m-p/797945#M313734</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-23T06:22:10Z</dc:date>
    </item>
  </channel>
</rss>

