<?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: Copy SAS files from SAS catalogue to a location on Windows in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Copy-SAS-files-from-SAS-catalogue-to-a-location-on-Windows/m-p/42366#M11028</link>
    <description>Deepu&lt;BR /&gt;
you say you "can view the SAS files", so I'll assume that these are are catalog entries of type SOURCE. (i would not expect to view the contents of a compiled macro).&lt;BR /&gt;
The following CODE assigns two "aggregate storage locations". First pointing at your catalog, Second is pointing at a folder in which you want to write the SAS files.[pre]filename sfrom catalog 'libname.catname'       ;&lt;BR /&gt;
filename sto         'your destination path\'   ;&lt;BR /&gt;
* now create a dataset listing all source entries in the catalog ;&lt;BR /&gt;
proc sql noprint ;&lt;BR /&gt;
    create table work.sources as&lt;BR /&gt;
          select objname from dictionary.catalogs&lt;BR /&gt;
           where libname='LIBNAME' and memname='CATNAME'&lt;BR /&gt;
             and objtype='SOURCE' ;&lt;BR /&gt;
quit ;&lt;BR /&gt;
data _null_ ; * now do the copies ;   &lt;BR /&gt;
   set  work.sources ;&lt;BR /&gt;
   length from_obj to_textf $80  ;&lt;BR /&gt;
   retain sto "%sysfunc(pathname(sto))" ; &lt;BR /&gt;
   to_textf = cats( sto,'\', objname, '.sas' );&lt;BR /&gt;
   from_obj = cats( 'libname.catname.', objname, '.source' ) ;&lt;BR /&gt;
   putLog  'reading from ' from_obj +1 'to write ' to_textf  ;&lt;BR /&gt;
   eof_cat_entry = . ;   &lt;BR /&gt;
   infile dum device=catalog  filevar= from_obj  end= eof_cat_entry ;&lt;BR /&gt;
     file dmy                 filevar= to_textf   ;&lt;BR /&gt;
   do lines=0 by 1 while( not eof_cat_entry ) ;&lt;BR /&gt;
      input ;&lt;BR /&gt;
      L= length( _infile_ ) ;&lt;BR /&gt;
      put _infile_  $varying256. L ;&lt;BR /&gt;
    end ;&lt;BR /&gt;
    putlog 'wrote ' lines +1 'lines.' ;&lt;BR /&gt;
run ;  [/PRE]&lt;BR /&gt;
On testing, I couldn't make the FILEVAR= feature support "aggregate storage location" filerefs. (you may be more sucessful).&lt;BR /&gt;
a piece of sas history convenience :: in the syntax [pre]  %include sfrom(program1) ;[/pre]"sfrom" is an aggregate storage location also known as a logical reference that points to a folder, directory or catalog, or pds (subject to the platform terminology).&lt;BR /&gt;
It serves the purpose of abbreviating the syntax (logical reference is allowed only an 8-wide SAS name) and being defined once and used many times, the logical reference reduces the number of places referring to physical paths.[pre]           sfrom(program1) [/pre]refers to a program file named program1.sas or program1.source, or program1.catams or just "program1" (depending on the platform and certain system options) in that aggregate storage location. Because of this convenience, an aggregate storage locations often called a "program library".&lt;BR /&gt;
//end of history&lt;BR /&gt;
fortunately, the base sas language provides the functions and operators which enable the code above to convert from logical reference to physical reference.</description>
    <pubDate>Thu, 01 Jul 2010 14:09:35 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2010-07-01T14:09:35Z</dc:date>
    <item>
      <title>Copy SAS files from SAS catalogue to a location on Windows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copy-SAS-files-from-SAS-catalogue-to-a-location-on-Windows/m-p/42362#M11024</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
In my project the sas files are kept in SAS catalogue. I can view the SAS files from the catalogue from Base SAS but I need to copy these sas files out of SAS cataloge to a location of windows.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Please suggest.</description>
      <pubDate>Wed, 30 Jun 2010 10:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copy-SAS-files-from-SAS-catalogue-to-a-location-on-Windows/m-p/42362#M11024</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-06-30T10:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Copy SAS files from SAS catalogue to a location on Windows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copy-SAS-files-from-SAS-catalogue-to-a-location-on-Windows/m-p/42363#M11025</link>
      <description>To Clarify my requirement, in my case all the SAS source files have been kept in a SAS Catalogue. My requirement is to send some of the SAS source files to analytics user from the catalogue. Is there any way to get the sas files out of catalogue so that i can send only the required sas files.</description>
      <pubDate>Wed, 30 Jun 2010 10:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copy-SAS-files-from-SAS-catalogue-to-a-location-on-Windows/m-p/42363#M11025</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-06-30T10:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Copy SAS files from SAS catalogue to a location on Windows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copy-SAS-files-from-SAS-catalogue-to-a-location-on-Windows/m-p/42364#M11026</link>
      <description>If I understand you right then all the SAS source code is stored as compiled macros in a macro catalogue together with the uncompiled source code.&lt;BR /&gt;
&lt;BR /&gt;
If so then check if %COPY does what you need: &lt;A href="http://support.sas.com/onlinedoc/913/getDoc/en/mcrolref.hlp/a002582616.htm" target="_blank"&gt;http://support.sas.com/onlinedoc/913/getDoc/en/mcrolref.hlp/a002582616.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Wed, 30 Jun 2010 11:29:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copy-SAS-files-from-SAS-catalogue-to-a-location-on-Windows/m-p/42364#M11026</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-06-30T11:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: Copy SAS files from SAS catalogue to a location on Windows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copy-SAS-files-from-SAS-catalogue-to-a-location-on-Windows/m-p/42365#M11027</link>
      <description>Hi:&lt;BR /&gt;
  There are many different types of catalogue entries that you could have. The ENTRY type is determined by the "4 level name" -- here are some examples:&lt;BR /&gt;
[pre]&lt;BR /&gt;
library.catalog.program.source&lt;BR /&gt;
library.catalog.program.scl&lt;BR /&gt;
library.catalog.program.macro&lt;BR /&gt;
library.catalog.entryname.format&lt;BR /&gt;
library.catalog.graphname.grseg&lt;BR /&gt;
library.catalog.entryname.program&lt;BR /&gt;
library.catalog.entryname.menu&lt;BR /&gt;
library.catalog.entryname.list&lt;BR /&gt;
[/pre]  &lt;BR /&gt;
                            &lt;BR /&gt;
For macro-related entries (if that is what you have), the documentation for the %COPY syntax is here:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#/documentation/cdl/en/mcrolref/61885/HTML/default/a002582616.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#/documentation/cdl/en/mcrolref/61885/HTML/default/a002582616.htm&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
Otherwise, look at the syntax for the CATALOG procedure:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#/documentation/cdl/en/proc/61895/HTML/default/a002473346.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#/documentation/cdl/en/proc/61895/HTML/default/a002473346.htm&lt;/A&gt;&lt;BR /&gt;
and the COPY example:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#/documentation/cdl/en/proc/61895/HTML/default/a002473355.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#/documentation/cdl/en/proc/61895/HTML/default/a002473355.htm&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 30 Jun 2010 15:18:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copy-SAS-files-from-SAS-catalogue-to-a-location-on-Windows/m-p/42365#M11027</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-06-30T15:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Copy SAS files from SAS catalogue to a location on Windows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copy-SAS-files-from-SAS-catalogue-to-a-location-on-Windows/m-p/42366#M11028</link>
      <description>Deepu&lt;BR /&gt;
you say you "can view the SAS files", so I'll assume that these are are catalog entries of type SOURCE. (i would not expect to view the contents of a compiled macro).&lt;BR /&gt;
The following CODE assigns two "aggregate storage locations". First pointing at your catalog, Second is pointing at a folder in which you want to write the SAS files.[pre]filename sfrom catalog 'libname.catname'       ;&lt;BR /&gt;
filename sto         'your destination path\'   ;&lt;BR /&gt;
* now create a dataset listing all source entries in the catalog ;&lt;BR /&gt;
proc sql noprint ;&lt;BR /&gt;
    create table work.sources as&lt;BR /&gt;
          select objname from dictionary.catalogs&lt;BR /&gt;
           where libname='LIBNAME' and memname='CATNAME'&lt;BR /&gt;
             and objtype='SOURCE' ;&lt;BR /&gt;
quit ;&lt;BR /&gt;
data _null_ ; * now do the copies ;   &lt;BR /&gt;
   set  work.sources ;&lt;BR /&gt;
   length from_obj to_textf $80  ;&lt;BR /&gt;
   retain sto "%sysfunc(pathname(sto))" ; &lt;BR /&gt;
   to_textf = cats( sto,'\', objname, '.sas' );&lt;BR /&gt;
   from_obj = cats( 'libname.catname.', objname, '.source' ) ;&lt;BR /&gt;
   putLog  'reading from ' from_obj +1 'to write ' to_textf  ;&lt;BR /&gt;
   eof_cat_entry = . ;   &lt;BR /&gt;
   infile dum device=catalog  filevar= from_obj  end= eof_cat_entry ;&lt;BR /&gt;
     file dmy                 filevar= to_textf   ;&lt;BR /&gt;
   do lines=0 by 1 while( not eof_cat_entry ) ;&lt;BR /&gt;
      input ;&lt;BR /&gt;
      L= length( _infile_ ) ;&lt;BR /&gt;
      put _infile_  $varying256. L ;&lt;BR /&gt;
    end ;&lt;BR /&gt;
    putlog 'wrote ' lines +1 'lines.' ;&lt;BR /&gt;
run ;  [/PRE]&lt;BR /&gt;
On testing, I couldn't make the FILEVAR= feature support "aggregate storage location" filerefs. (you may be more sucessful).&lt;BR /&gt;
a piece of sas history convenience :: in the syntax [pre]  %include sfrom(program1) ;[/pre]"sfrom" is an aggregate storage location also known as a logical reference that points to a folder, directory or catalog, or pds (subject to the platform terminology).&lt;BR /&gt;
It serves the purpose of abbreviating the syntax (logical reference is allowed only an 8-wide SAS name) and being defined once and used many times, the logical reference reduces the number of places referring to physical paths.[pre]           sfrom(program1) [/pre]refers to a program file named program1.sas or program1.source, or program1.catams or just "program1" (depending on the platform and certain system options) in that aggregate storage location. Because of this convenience, an aggregate storage locations often called a "program library".&lt;BR /&gt;
//end of history&lt;BR /&gt;
fortunately, the base sas language provides the functions and operators which enable the code above to convert from logical reference to physical reference.</description>
      <pubDate>Thu, 01 Jul 2010 14:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copy-SAS-files-from-SAS-catalogue-to-a-location-on-Windows/m-p/42366#M11028</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-07-01T14:09:35Z</dc:date>
    </item>
  </channel>
</rss>

