<?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: Running PROC COPY multiple times in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Running-PROC-COPY-multiple-times/m-p/806837#M317964</link>
    <description>&lt;P&gt;A libname statement can be assigned to cover a collection of other libnames (or a list of directories).&amp;nbsp; So a proc copy could transcribe all the datasets in a collection of libraries (each listed in the "aggregate" library) to a destination library.&amp;nbsp; Here's an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname sdat1 'c:\temp\sasdata1';
libname sdat2 'c:\temp\sasdata2';

data sdat1.class; set sashelp.class; run;
data sdat2.cars; set sashelp.cars; run;


libname srclibs (sdat1 sdat2);
libname tmp 'c:\temp';
proc copy out=tmp in=srclibs ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The log reports copying both datasets, one from each SDATx library, to the TMP library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;418  libname srclibs (sdat1 sdat2);
NOTE: Libref SRCLIBS was successfully assigned as follows:
      Levels:           2
      Engine(1):        V9
      Physical Name(1): c:\temp\sasdata1
      Engine(2):        V9
      Physical Name(2): c:\temp\sasdata2
419  libname tmp 'c:\temp';
NOTE: Libref TMP was successfully assigned as follows:
      Engine:        V9
      Physical Name: c:\temp
420  proc copy out=tmp in=srclibs ;
421  run;

NOTE: Copying SRCLIBS.CARS to TMP.CARS (memtype=DATA).
NOTE: There were 428 observations read from the data set SRCLIBS.CARS.
NOTE: The data set TMP.CARS has 428 observations and 15 variables.
NOTE: Copying SRCLIBS.CLASS to TMP.CLASS (memtype=DATA).
NOTE: There were 19 observations read from the data set SRCLIBS.CLASS.
NOTE: The data set TMP.CLASS has 19 observations and 5 variables.
NOTE: PROCEDURE COPY used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no idea whether this behavior is replicated when reading from a collection of XPORT-engine libraries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also: if a dataset name appears in multiple locations in the "collective" library, then, in my experience, only the first one (i.e. the leftmost library) is accessed.&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;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Apr 2022 19:40:33 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2022-04-08T19:40:33Z</dc:date>
    <item>
      <title>Running PROC COPY multiple times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-PROC-COPY-multiple-times/m-p/806835#M317963</link>
      <description>&lt;P&gt;I'm using some old syntax - that I didn't write and don't understand very well - to create SAS data sets from .xpt files.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* -------------------------------------------------------------------------------------------------------------------;
************************************************** 2013-2014 ********************************************************;
* -------------------------------------------------------------------------------------------------------------------;
* Demographics;
LIBNAME xptfile xport '/home/myname/Projects/NHANES/XPT Files/DEMO_H.XPT' access=readonly;
* Drug Use;
LIBNAME xptfile xport '/home/myname/Projects/NHANES/XPT Files/DUQ_H.XPT' access=readonly;
* Medical Conditions;
LIBNAME xptfile xport '/home/myname/Projects/NHANES/XPT Files/MCQ_H.XPT' access=readonly;
* Prescription Medications - Drug Information;
LIBNAME xptfile xport '/home/myname/Projects/NHANES/XPT Files/RXQ_DRUG.XPT' access=readonly;
* Prescription Medications;
LIBNAME xptfile xport '/home/myname/Projects/NHANES/XPT Files/RXQ_RX_H.XPT' access=readonly;
* Cigarette Use;
LIBNAME xptfile xport '/home/myname/Projects/NHANES/XPT Files/SMQ_H.XPT' access=readonly;
* Recent Tobacco Use;
LIBNAME xptfile xport '/home/myname/Projects/NHANES/XPT Files/SMQRTU_H.XPT' access=readonly;

PROC COPY INLIB=xptfile OUTLIB=nhanes;
RUN;
&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is there a way to run this once and have all .xpt files in the "xptfile" library copied into the "nhanes" library as SAS data sets?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently, I need to run each LIBNAME statement individually and then run the PROC COPY. Not very efficient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 19:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-PROC-COPY-multiple-times/m-p/806835#M317963</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2022-04-08T19:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Running PROC COPY multiple times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-PROC-COPY-multiple-times/m-p/806837#M317964</link>
      <description>&lt;P&gt;A libname statement can be assigned to cover a collection of other libnames (or a list of directories).&amp;nbsp; So a proc copy could transcribe all the datasets in a collection of libraries (each listed in the "aggregate" library) to a destination library.&amp;nbsp; Here's an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname sdat1 'c:\temp\sasdata1';
libname sdat2 'c:\temp\sasdata2';

data sdat1.class; set sashelp.class; run;
data sdat2.cars; set sashelp.cars; run;


libname srclibs (sdat1 sdat2);
libname tmp 'c:\temp';
proc copy out=tmp in=srclibs ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The log reports copying both datasets, one from each SDATx library, to the TMP library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;418  libname srclibs (sdat1 sdat2);
NOTE: Libref SRCLIBS was successfully assigned as follows:
      Levels:           2
      Engine(1):        V9
      Physical Name(1): c:\temp\sasdata1
      Engine(2):        V9
      Physical Name(2): c:\temp\sasdata2
419  libname tmp 'c:\temp';
NOTE: Libref TMP was successfully assigned as follows:
      Engine:        V9
      Physical Name: c:\temp
420  proc copy out=tmp in=srclibs ;
421  run;

NOTE: Copying SRCLIBS.CARS to TMP.CARS (memtype=DATA).
NOTE: There were 428 observations read from the data set SRCLIBS.CARS.
NOTE: The data set TMP.CARS has 428 observations and 15 variables.
NOTE: Copying SRCLIBS.CLASS to TMP.CLASS (memtype=DATA).
NOTE: There were 19 observations read from the data set SRCLIBS.CLASS.
NOTE: The data set TMP.CLASS has 19 observations and 5 variables.
NOTE: PROCEDURE COPY used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no idea whether this behavior is replicated when reading from a collection of XPORT-engine libraries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also: if a dataset name appears in multiple locations in the "collective" library, then, in my experience, only the first one (i.e. the leftmost library) is accessed.&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 19:40:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-PROC-COPY-multiple-times/m-p/806837#M317964</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-04-08T19:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Running PROC COPY multiple times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-PROC-COPY-multiple-times/m-p/806919#M318015</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname x xport ('c:\temp\stocks.xpt' 'c:\temp\class.xpt' );
proc copy in=x out=work;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Apr 2022 10:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-PROC-COPY-multiple-times/m-p/806919#M318015</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-04-09T10:33:51Z</dc:date>
    </item>
  </channel>
</rss>

