<?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: Extracting source elements from catalog - how to? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309429#M66549</link>
    <description>&lt;P&gt;I don't know if %include will work, since that submits the code and all I want to do is&amp;nbsp;save it as a ProgramName1.sas file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I edited my original post with more info on what I'm trying to do. Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 04 Nov 2016 21:42:53 GMT</pubDate>
    <dc:creator>JSWilson64</dc:creator>
    <dc:date>2016-11-04T21:42:53Z</dc:date>
    <item>
      <title>Extracting source elements from catalog - how to?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309419#M66541</link>
      <description>&lt;P&gt;I have "inherited" as SAS catalog that contains several dozen program elements. I need to pull the elements out into individual SAS program files. Seems like a simple task... I just can't seem to figure out how to do it. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using desktop SAS on Windows 7, if that matters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I'm hoping to be able to do is get the names of the program elements in the catalog (I know how to do this) and write a SAS program that will take each program element and output it as a SAS program file. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So something like &amp;nbsp; &amp;nbsp;MyLib.Mycat.MyProgram1.Source &amp;nbsp; &amp;nbsp; &amp;nbsp;becomes &amp;nbsp; &amp;nbsp; d:\MyFolder\Myprogram1.sas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd rather not have to manually save and name each file for referential integrity with other programs that access the catalogs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2016 21:41:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309419#M66541</guid>
      <dc:creator>JSWilson64</dc:creator>
      <dc:date>2016-11-04T21:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting source elements from catalog - how to?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309423#M66544</link>
      <description>&lt;P&gt;The FILENAME statement can help you here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#n0e720f80cp61wn1mplyz2xy2aeu.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#n0e720f80cp61wn1mplyz2xy2aeu.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then use %include or from your command line INCLUDE &lt;EM&gt;fileref&lt;/EM&gt; to bring the source code into the SAS editor.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2016 21:18:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309423#M66544</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-11-04T21:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting source elements from catalog - how to?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309429#M66549</link>
      <description>&lt;P&gt;I don't know if %include will work, since that submits the code and all I want to do is&amp;nbsp;save it as a ProgramName1.sas file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I edited my original post with more info on what I'm trying to do. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2016 21:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309429#M66549</guid>
      <dc:creator>JSWilson64</dc:creator>
      <dc:date>2016-11-04T21:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting source elements from catalog - how to?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309437#M66554</link>
      <description>&lt;P&gt;%COPY?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/67912/HTML/default/viewer.htm#p0oltlodtnemugn109vxxa76sref.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/67912/HTML/default/viewer.htm#p0oltlodtnemugn109vxxa76sref.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes that the source was actually saved in the catalog, and not just the compiled program....if it's just the compiled program you might be out&amp;nbsp;of luck.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2016 22:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309437#M66554</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-04T22:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting source elements from catalog - how to?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309452#M66567</link>
      <description>&lt;P&gt;Just use INCLUDE &lt;EM&gt;fileref&lt;/EM&gt; then - that will extract the source program into the SAS editor without running it. From there you can SAVE it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename dir catalog 'mylib.mycatalog';
dm 'include dir(prog1)';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Nov 2016 00:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309452#M66567</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-11-05T00:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting source elements from catalog - how to?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309453#M66568</link>
      <description>&lt;P&gt;Just use a DATA _NULL_ step to copy the lines.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let memname=fred ;
data _null_;
  infile "work.mycat.&amp;amp;memname..source" catalog ;
  file "~/test/&amp;amp;memname..sas";
  input;
  put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Nov 2016 00:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309453#M66568</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-11-05T00:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting source elements from catalog - how to?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309482#M66591</link>
      <description>&lt;PRE&gt;

data pgm=stored.sample;
describe;
run;

&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Nov 2016 08:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309482#M66591</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-11-05T08:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting source elements from catalog - how to?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309887#M66779</link>
      <description>&lt;P&gt;Thanks, Tom. This worked great, with the least amount of effort on my part. I used the CONTENTS option in Proc Catalog to list out the objects in the catalog, then used&amp;nbsp;Excel&amp;nbsp;to build some repetitive data step statements to save each item out into a SAS program file with the same name.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2016 21:59:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309887#M66779</guid>
      <dc:creator>JSWilson64</dc:creator>
      <dc:date>2016-11-07T21:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting source elements from catalog - how to?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309917#M66790</link>
      <description>&lt;P&gt;Excel???????? &amp;nbsp;Why the heck would you use Excel to generate SAS code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let catalog=work.mycat ;
%let dir=~/test ;
filename code temp;
data _null_;
  set sashelp.vcatalg ;
  where libname="%upcase(%scan(&amp;amp;catalog,1,'.'))"
    and memname="%upcase(%scan(&amp;amp;catalog,2,'.'))"
    and objtype='SOURCE'
  ;
  length catalog fname $200 ;
  catalog=catx('.',"&amp;amp;catalog",objname,objtype);
  fname = catx('/',"&amp;amp;dir",cats(lowcase(objname),'.sas'));
  file code ;
  put 'data _null_;'
    / '  infile ' catalog :$quote. 'catalog;'
    / '  file ' fname :$quote. ';'
    / '  input;'
    / '  put _infile_;'
    / 'run;'
  ;
run;
%include code ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2016 01:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-source-elements-from-catalog-how-to/m-p/309917#M66790</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-11-08T01:08:15Z</dc:date>
    </item>
  </channel>
</rss>

