<?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 dataset within same library to new dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Copy-dataset-within-same-library-to-new-dataset/m-p/122393#M33637</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Bruno, that solution works for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I run it using my original solution compared to this one, the times are roughly the same, which is good.&amp;nbsp; And the fact that the indexes are maintained is exactly what I was after.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Aug 2013 23:07:44 GMT</pubDate>
    <dc:creator>JohnT</dc:creator>
    <dc:date>2013-08-27T23:07:44Z</dc:date>
    <item>
      <title>Copy dataset within same library to new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copy-dataset-within-same-library-to-new-dataset/m-p/122389#M33633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;I'm trying to replicate a dataset (refreshed daily) in a library based on whether it's the first of the month or not.&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;I this I want to use a PROC because it's possible I might change the indexes on the dataset in the future.&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;data cls (index = (name) );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;BR /&gt;run;&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;proc datasets library = work;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; change cls = cls2; run;&lt;BR /&gt;quit;&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;proc contents data = work.cls2;&lt;BR /&gt;run;&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;data cls3 (index = (name) );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set cls;&lt;BR /&gt;run;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;^^&lt;BR /&gt;The first two datasteps kind of do what I'm after, but it removes the cls dataset, which I want to retain. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The third datastep was there for me to check that the index was still there after the change (and it was).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The final datastep is my current solution, but I don't really want to essentially recreate the dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm running SAS 9.3 using Enterprise Guide 5.1 (5.100.0.12269) Hot fix 7 (32-bit)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 00:29:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copy-dataset-within-same-library-to-new-dataset/m-p/122389#M33633</guid>
      <dc:creator>JohnT</dc:creator>
      <dc:date>2013-08-27T00:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: Copy dataset within same library to new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copy-dataset-within-same-library-to-new-dataset/m-p/122390#M33634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So . . . you want to keep the original dataset (CLS), and you don't need the final dataset (CLS3)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 00:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copy-dataset-within-same-library-to-new-dataset/m-p/122390#M33634</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2013-08-27T00:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Copy dataset within same library to new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copy-dataset-within-same-library-to-new-dataset/m-p/122391#M33635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry I should have been more specific.&amp;nbsp; Ignore the last two steps, I want CLS and CLS2, they were just for checking and demonstrating my current solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data cls (index = (name) );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc datasets library = work;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; change cls = cls2; run;&lt;BR /&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 00:41:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copy-dataset-within-same-library-to-new-dataset/m-p/122391#M33635</guid>
      <dc:creator>JohnT</dc:creator>
      <dc:date>2013-08-27T00:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Copy dataset within same library to new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copy-dataset-within-same-library-to-new-dataset/m-p/122392#M33636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi JohnT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can not copy a SAS Data Set within the same library. However you can use other statements from Proc DATASETS to achieve the same. Have a look at the code below. It will delete an existing CLS2 data set. It then uses the APPEND statement, if the base table is not found, then append will make a copy of the data table and preserve index etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Consolas; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; cls (&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;index&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; = (name) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;label&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"Original CLS"&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; sashelp.class;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;datasets&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;library&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; = work;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;delete&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; cls2;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;append&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=cls &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;base&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=cls2;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 07:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copy-dataset-within-same-library-to-new-dataset/m-p/122392#M33636</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2013-08-27T07:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Copy dataset within same library to new dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Copy-dataset-within-same-library-to-new-dataset/m-p/122393#M33637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Bruno, that solution works for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I run it using my original solution compared to this one, the times are roughly the same, which is good.&amp;nbsp; And the fact that the indexes are maintained is exactly what I was after.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Aug 2013 23:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Copy-dataset-within-same-library-to-new-dataset/m-p/122393#M33637</guid>
      <dc:creator>JohnT</dc:creator>
      <dc:date>2013-08-27T23:07:44Z</dc:date>
    </item>
  </channel>
</rss>

