<?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: More efficient way to copy with a where statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276828#M55505</link>
    <description>&lt;P&gt;This is best situation for PROC DS2.&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;
libname y v9 '/folders/myfolders/';
data y.class;
 set sashelp.class;
run;

proc ds2;
data Female(overwrite=yes);
method run();
 set y.class;
 if sex='F';
end;
enddata;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 Jun 2016 02:00:40 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-06-13T02:00:40Z</dc:date>
    <item>
      <title>More efficient way to copy with a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276766#M55487</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm taking a dataset with 54 million records and want to subset it to another location with a where statement.&amp;nbsp; By default, i'm doing this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data out.PS&amp;amp;year._2015 (where=(hcfasaf="P"));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;set clm2015.ps&amp;amp;year.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it's taking about 45 minutes and i have to do 11 years worth.&amp;nbsp; I looked into proc copy, but there's no where= statement that works with that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Megan&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 14:36:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276766#M55487</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2016-06-12T14:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way to copy with a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276767#M55488</link>
      <description>Have you considered creating an index on column hcfasaf? Once you want to subset your data most approaches take the same path behind the scenes. If you say "another location" have a look at other aspecs as well, like network bandwidth and I/O contention. If your source and target reside on the same on the Sam disk(s) then that may actually be your problem and not SAS.&lt;BR /&gt;&lt;BR /&gt;Regards Jan.</description>
      <pubDate>Sun, 12 Jun 2016 14:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276767#M55488</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-06-12T14:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way to copy with a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276768#M55489</link>
      <description>&lt;P&gt;There already is an index on the dataset, but on different variables. If were to create an index, i'd have to create a new copy anyway, b/c i can't modify what's there or it'll remove what currently exists and what's there is standard.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And i'm copying to and from the same server.&amp;nbsp; I don't know what an aspec is.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 14:53:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276768#M55489</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2016-06-12T14:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way to copy with a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276772#M55491</link>
      <description>&lt;P&gt;If the data has to travel over the network (ie SAS and the dataset do not reside in the same host), then 45 minutes is actually quite fast.&lt;/P&gt;
&lt;P&gt;If everything is on the same server, you may have the problem of competing disk accesses.&lt;/P&gt;
&lt;P&gt;For operations like this, I try to make source and target storage physically separate (source on SAN, target on internal disks; or source on one physical volume, target on another).&lt;/P&gt;
&lt;P&gt;Have you tried the (compress=yes) dataset option on the target dataset? With (large) string variables present this can significantly reduce storage use and therefore I/O.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 16:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276772#M55491</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-12T16:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way to copy with a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276775#M55492</link>
      <description>&lt;P&gt;With "aspects" I mean all those factors that determine the performance of the task at hand. There are many ways to do things in SAS and often performance relies heaviliy on the choices you make. But your SAS code it is not the only thing to look at. Your system components (CPU, memory, I/O) are important players here. If your source and target are on the same server there is a chance they are also on the same disks. For best performance it is important that this situation is avoided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On a side note it is surprising to hear you need to recreate all indexes when adding one. Could you explain a bit more why this would be the case?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And please keep in mind that at the end of the day you may just have to wait, as the task you try to perform takes a while because of the large volumes you are processing. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 16:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276775#M55492</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-06-12T16:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way to copy with a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276777#M55493</link>
      <description>&lt;P&gt;Your use of the WHERE statement could be improved. &amp;nbsp;By putting it on the DATA statement, the program reads in all observations and only subsets the output. &amp;nbsp;Move it here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;data out.PS&amp;amp;year._2015;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;set clm2015.ps&amp;amp;year. (where=(hcfasaf="P"));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That way, the program will subset the observations on the way in instead of on the way out.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 16:28:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276777#M55493</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-12T16:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way to copy with a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276782#M55495</link>
      <description>&lt;P&gt;I would follow&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;'s suggestion&amp;nbsp;&lt;EM&gt;if the subset is comparably small&lt;/EM&gt; (i.e., say, only &amp;lt;50% of the observations meet the WHERE condition). If, on the contrary, the subset is large, a subsetting IF (&lt;FONT face="courier new,courier"&gt;if hcfasaf='P';&lt;/FONT&gt;) might be faster than the approach using WHERE.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 16:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276782#M55495</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-06-12T16:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way to copy with a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276828#M55505</link>
      <description>&lt;P&gt;This is best situation for PROC DS2.&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;
libname y v9 '/folders/myfolders/';
data y.class;
 set sashelp.class;
run;

proc ds2;
data Female(overwrite=yes);
method run();
 set y.class;
 if sex='F';
end;
enddata;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jun 2016 02:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276828#M55505</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-06-13T02:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way to copy with a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276829#M55506</link>
      <description>&lt;P&gt;1- You can create a new index without removing anything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; For example using&amp;nbsp; proc sql; create index ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2- Please post the log times so we know whether the issue is I/O (likely)&amp;nbsp;or CPU. &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If you are copying to the same disk sub-system, speed will be low. To such en extend that it can be faster to &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; make&amp;nbsp;two copy operations. For example to the WORK library and then from WORK&amp;nbsp;to the final destination.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;3- As outlined by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;, the where clause should probably be moved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4- See &lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/How-to-speed-up-performance-of-Sas-9-4-TS1M3-through-enterprise/m-p/276653" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/How-to-speed-up-performance-of-Sas-9-4-TS1M3-through-enterprise/m-p/276653&lt;/A&gt; where speeding up data access is also discussed. Compression and memory usage in particular could make a difference in your case.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 02:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276829#M55506</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-06-13T02:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way to copy with a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276914#M55532</link>
      <description>&lt;P&gt;I just meant that i can't modify existing indexes.&amp;nbsp; This isn't "my" dataset, it belongs to the department.&amp;nbsp; I can't go changing things like that.&amp;nbsp; Other people use these datasets.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 13:01:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276914#M55532</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2016-06-13T13:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: More efficient way to copy with a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276921#M55536</link>
      <description>&lt;P&gt;Thanks!&amp;nbsp; I ran this on a test case and my original way was 2 minutes, this one was 14 seconds.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 13:11:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-efficient-way-to-copy-with-a-where-statement/m-p/276921#M55536</guid>
      <dc:creator>MeganE</dc:creator>
      <dc:date>2016-06-13T13:11:16Z</dc:date>
    </item>
  </channel>
</rss>

