<?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: Combining multiple SAS datasets while maintaining sort order? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456134#M115508</link>
    <description>&lt;P&gt;Get a lot of fast disks?&amp;nbsp; I/O is usually the bottle neck with SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check if your system has some large fast disks reserved for temporary files and try to use those.&amp;nbsp; I have had some success with use OS commands to copy large gzipped files from regular disks to the SAS work disk and then reading them.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SPDE should help with every step.&amp;nbsp; You can spread the SAS datasets across multiple disks. Make sure they are using different IO controllers if you can.&amp;nbsp; You can use COMPRESS=BINARY with SPDE engine and get much better compression that with BASE engine.&amp;nbsp; If nothing else that should save a lot of I/O.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think you can multi-thread reading from a single large GZIP file. So you might speed up the first step by getting the large file delivered as multiple small files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 21 Apr 2018 02:53:16 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-04-21T02:53:16Z</dc:date>
    <item>
      <title>Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456052#M115477</link>
      <description>&lt;P&gt;I'm combining a series of 28&amp;nbsp;SAS datasets all of which are sorted by a common numeric key.&amp;nbsp; I want the final output to be a single SAS data set sorted by the common numeric key.&amp;nbsp; Right now, I'm doing an an "interleave", that is a DATA step with a series of SET statements (one for each dataset) immediately followed by a BY statement specifying the common numeric key.&amp;nbsp; The result is a single SAS dataset the entirety of which is sorted by the aforementioned common numeric key.&amp;nbsp;The combined total record count is around 230 million rows with about 480 columns.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Timings:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Reading the raw files to create the 28 SAS datasets takes &lt;STRONG&gt;45 minutes&lt;/STRONG&gt;.&lt;/LI&gt;
&lt;LI&gt;The interleave takes &lt;STRONG&gt;90 minutes&lt;/STRONG&gt; (double the time to read).&lt;/LI&gt;
&lt;LI&gt;The follow on analytical steps take &lt;STRONG&gt;45 minutes&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;TOTAL&lt;/STRONG&gt;: about &lt;STRONG&gt;3 hours&lt;/STRONG&gt;, half of which is the interleave.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is on a 20 core (80 logical core) AIX machine with 252 Gb of memory running SAS 9.4 M4.&amp;nbsp; The raw input files are ASCII csv files.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;QUESTION:&amp;nbsp; Is there a faster way to do the interleave?&amp;nbsp; The performance isn't bad.&amp;nbsp; Originally it was running 9 hours before I split the largest file (about 180 million rows) into 25 smaller files, but since the interleave is 50% of the total, it would be nice to cut it down to less than or equal the time it takes to read in the data.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All of the files, after splitting the largest file into 25 files, are small enough that they can&amp;nbsp;be loaded into a hash tables.&amp;nbsp; I'm not sure that all 28 files could be loaded into hash tables in a single DATA step, but no single file is so large that it can't be loaded into a hash table.&amp;nbsp; I've loaded up to three files into hash tables in a single data step in the testing I've done so far.&amp;nbsp; However, I&amp;nbsp;am not aware of any method of using hash tables to combine all 230 million rows that offers the possibility that it would be faster than the interleave that I'm already doing.&amp;nbsp; &amp;nbsp;Are there any hash techniques out there that I'm just not aware of?&amp;nbsp; I need to keep all rows from all 28 SAS datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Any ideas on how I might combine these 28 datasets while maintaining sort order faster than a SAS interleave?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have not tried using SPDE for the 28 datasets.&amp;nbsp; SPDE is not something I've used before.&amp;nbsp; Would that have any potential at all to make things significantly faster?&amp;nbsp; SPDG is not available in our environment.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe I'm just whining since I've already got the job down from 9 hours to 3, but since we frequently deal with datasets of 250+ million rows, I'd love&amp;nbsp;to know about it if there were faster techniques to combine large SAS datasets while maintaining sort order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 19:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456052#M115477</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2018-04-20T19:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456068#M115483</link>
      <description>&lt;P&gt;How about&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Loading all your datasets&amp;nbsp; into hash object 1&lt;/P&gt;&lt;P&gt;2. loading all your unique keys into hash object 2&lt;/P&gt;&lt;P&gt;3. instantiate hiter&amp;nbsp; and iterate through the keys of hash object 2&lt;/P&gt;&lt;P&gt;4. while iterating look up hash object1 for each unique key from the PDV extract all observations and write out to the output dataset&lt;/P&gt;&lt;P&gt;5. Point 1 will require one full pass of using dataset names in the declare statement instantiation though and then hiter can take over&lt;/P&gt;&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 20:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456068#M115483</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-20T20:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456086#M115487</link>
      <description>&lt;P&gt;Interesting.&amp;nbsp; I think the second hash table might not be necessary if all data can be loaded into the first hash table although maybe I'm not understanding your idea.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I specify "ordered:a" on the first hash table, all records will be automatically in order.&amp;nbsp; I then need to do a hash_table1.OUTPUT(dataset:'sasout.output_data') .&amp;nbsp; I believe this would require two passes through the data:&amp;nbsp; 1.&amp;nbsp; Load the hash table&amp;nbsp; 2.&amp;nbsp; Write the hash table.&amp;nbsp;&amp;nbsp;Still, it would work.&amp;nbsp; I wonder if it would be faster.&amp;nbsp; I also wonder if I can really load 230 million records with each 480 columns into a hash table.&amp;nbsp; I have a big machine available, but that is a lot of data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 20:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456086#M115487</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2018-04-20T20:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456089#M115488</link>
      <description>&lt;P&gt;Hmm you are right. I am not sure if&amp;nbsp; this is approach is any faster. I guess that is something you can test in a dev environment and compare with traditional interleave.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;for -&lt;EM&gt;-"I also wonder if I can really load 230 million records with each 480 columns into a hash table.&amp;nbsp; I have a big machine available, but that is a lot of data"&lt;/EM&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hashexp: 20 should hold i think ???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Btw, My apporach of the second table is to zip through an an unsorted hash table as i was overthinking whether ordered option is perhaps expensive&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 20:57:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456089#M115488</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-20T20:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456103#M115497</link>
      <description>&lt;P&gt;I'm wondering, is syncsort any good at multi-threading?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 21:52:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456103#M115497</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-04-20T21:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456104#M115498</link>
      <description>&lt;P&gt;I don't know for sure, but my thought is that records are added to a hash table in sort order as they are read.&amp;nbsp; I think the hashing algorithm is such that the hash generated automatically places the record in sort order -- at least that's my&amp;nbsp;understanding.&amp;nbsp; I'll have to check some of Paul Dorfman's papers and see if I can find out exactly how that works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've done some hash sort tests (where I load a file into an ordered hash table and then write the file out in sort order from the hash table).&amp;nbsp; I've compared the time it takes to do a hash sort vs. one of the provided SAS sorts (traditional sort, multi-threaded sort, SQL sort, and tag sort), and hash sort is never as fast as the SAS procedures except maybe on small files.&amp;nbsp; Still, it might be interesting to try.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 22:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456104#M115498</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2018-04-20T22:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456108#M115500</link>
      <description>&lt;P&gt;A good question in that SYNCSORT is known to be pretty fast.&amp;nbsp; Alas, I don't have SYNCSORT available to me to run some tests.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 22:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456108#M115500</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2018-04-20T22:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456117#M115503</link>
      <description>&lt;P&gt;I am not sure I understand exactly what you are saying is your process.&amp;nbsp; Sounds like you are just trying to describe code like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set ds1-ds28 ;
  by key;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Why are you starting from text files instead of datasets?&amp;nbsp; Can't you just create the datasets once instead of spending 45 minutes each time to convert them from text into datasets?&amp;nbsp; Most SAS jobs are I/O bound so if the text files are compressed that might save time.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds1 ;
  infile 'file1.csv.gz' zip gzip dsd truncover firstobs=2;
  ....
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Do you have SAS/Connect?&amp;nbsp; Can you spin up N sessions to each read 28/N of the text files independently?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;waitfor _all_ ;
data want ;
  set server1.ds1 server1.ds2 server2.ds1 server2.ds2 ...... ;
  by key;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 23:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456117#M115503</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-20T23:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456121#M115504</link>
      <description>&lt;P&gt;Hi, Tom,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your illustration (set ds1 - ds28; by key; ) is &lt;EM&gt;exactly&lt;/EM&gt; what I'm doing -- after I've read in all the text files.&amp;nbsp; The files are csv but have been gzipped first.&lt;BR /&gt;&lt;BR /&gt;Why do I keep reading them in?&amp;nbsp; Well, these are from an external source.&amp;nbsp; We get a new set every month.&amp;nbsp; We get four files totaling about 220 to 250 million records, depending on the month.&amp;nbsp; One file is about a million, one about 30 to 35 million, one about 10 to 15 million, and the last one, by far the largest, is about 180 to 220 million records.&amp;nbsp; The job was originally single-threaded and took about 9 hours, including the analytical steps that follow the input and interleave steps.&amp;nbsp; Eek.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I took the largest file and, using multiple threads, read it into 25 separate SAS datasets.&amp;nbsp; The multi-threaded read of the largest file now takes 30 - 45 minutes instead of 4+ hours, depending on how many subordinate threads I use.&amp;nbsp; However, I then have to do the interleave, as you described (&lt;SPAN&gt;set ds1 - ds28; by key; ).&amp;nbsp; The interleave takes 90 minutes, which is 2 to 3 times how long it takes to read in the data.&amp;nbsp; Maybe that's the best that can be had, but I thought I'd ask if there were a faster way.&amp;nbsp; Taking a job from 9 hours run time to 3 hours is hardly disappointing, but, you know, I'd like to see if there are any other performance gains to be had if I can.&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;&lt;SPAN&gt;Jim&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;P.S.&amp;nbsp; W&lt;/SPAN&gt;&lt;SPAN&gt;e don't have MP Connect, but multi-threading can still be done through UNIX&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2018 00:16:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456121#M115504</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2018-04-21T00:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456122#M115505</link>
      <description>&lt;P&gt;If your datasets contain a lot of character columns then I would test the performance of using COMPRESS = BINARY dataset option. If the compression ratio is high, like over 50% I would expect your processing to speed up due to reduced IO.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2018 00:18:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456122#M115505</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-04-21T00:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456126#M115506</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried both binary and character compression.&amp;nbsp; Binary definitely creates a smaller file.&amp;nbsp; I'm not sure if I'm understanding you correctly -- would switching to character compression make things go faster?&amp;nbsp; That seems counter-intuitive, but I suppose I could try it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2018 01:23:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456126#M115506</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2018-04-21T01:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456132#M115507</link>
      <description>&lt;P&gt;If BINARY compresses your datasets the most I would stick with it - does it improve performance?&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2018 02:40:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456132#M115507</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-04-21T02:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456134#M115508</link>
      <description>&lt;P&gt;Get a lot of fast disks?&amp;nbsp; I/O is usually the bottle neck with SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check if your system has some large fast disks reserved for temporary files and try to use those.&amp;nbsp; I have had some success with use OS commands to copy large gzipped files from regular disks to the SAS work disk and then reading them.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SPDE should help with every step.&amp;nbsp; You can spread the SAS datasets across multiple disks. Make sure they are using different IO controllers if you can.&amp;nbsp; You can use COMPRESS=BINARY with SPDE engine and get much better compression that with BASE engine.&amp;nbsp; If nothing else that should save a lot of I/O.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think you can multi-thread reading from a single large GZIP file. So you might speed up the first step by getting the large file delivered as multiple small files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2018 02:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456134#M115508</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-04-21T02:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456136#M115509</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe binary compression improves performance since it's the smallest "footprint", but I haven't run any tests.&amp;nbsp; I suppose I should run three tests:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;COMPRESS=NO&lt;/LI&gt;
&lt;LI&gt;COMPRESS=CHAR&lt;/LI&gt;
&lt;LI&gt;COMPRESS=BINARY&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I'll try it when I get a chance although I suspect I'm already using the fastest option, binary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2018 03:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456136#M115509</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2018-04-21T03:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456138#M115510</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Interesting.&amp;nbsp; I'll have to try SPDE although I haven't as yet ever used it. I've read that optimal set up is not trivial.&amp;nbsp; I wasn't sure that SPDE would improve things for sequential access.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea of fast disks is interesting although taking the time to copy the raw data from our "landing zone" to another disk might negate the time savings obtained from using a faster disk.&amp;nbsp; Still, perhaps the SAS datasets themselves could be written to faster disks even if the raw data is on slower disks.&amp;nbsp; Perhaps conducting the interleave, the bottleneck, on the fast disks is the answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for multiple threads simultaneously reading a single gzipped file, it seems to be working fine.&amp;nbsp; In fact it's working fabulously.&amp;nbsp; Single threaded was 4 hours.&amp;nbsp; Multi-threaded is 45 minutes (or less if I go crazy on allocating threads), a 500% improvement in run time.&amp;nbsp; I'm doing a PIPE "gunzip -c&amp;nbsp;&lt;EM&gt;exciting_filename.csv"&amp;nbsp;&lt;/EM&gt;in my FILENAME statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2018 03:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456138#M115510</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2018-04-21T03:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456144#M115511</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37107"&gt;@jimbarbour&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Do you have to pre-sort your source data before the merge or is the data already sorted in source. IF it's already sorted then it would be worth to try and read and merge all the data in a single data step as this would save a full read/write cycle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option: Even if you don't have SAS Connect you could&amp;nbsp; still read all the gzipped sources in parallel using a job run in batch per source. If you don't have a scheduler then &lt;EM&gt;systask()&lt;/EM&gt; together with the &lt;EM&gt;waitfor&lt;/EM&gt; statement will allow you to control the whole process and dependencies from a single master job.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/hostunx/63053/HTML/default/viewer.htm#p0w8zwo1dyssdfn1mjm11dt2v7e2.htm&amp;nbsp;" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/hostunx/63053/HTML/default/viewer.htm#p0w8zwo1dyssdfn1mjm11dt2v7e2.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And last but not least: Using the SPDE engine remains worth trying.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2018 05:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456144#M115511</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-04-21T05:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456147#M115513</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been doing just what you suggest:&amp;nbsp; Using a SYSTASK with a NOWAIT parameter to launch multiple subordinate threads followed by a WAITFOR _ALL_.&amp;nbsp; Generally, it works very well, but be warned that you do &lt;EM&gt;not&lt;/EM&gt; want NOWORKINIT in your cfg file.&amp;nbsp; Ask me how I know that.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data is sorted when we get it, but I don't think combining the 28 datasets and reading them all in one DATA step will save time.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's why:&lt;/P&gt;
&lt;P&gt;Single threaded, the job takes 4 hours to read the largest data set, then 1.5 hours to interleave with the three other datasets.&amp;nbsp; Doing the combining in the same DATA step as the read would eliminate the 1.5 hours, but it would still take at least 4 hours to read in the largest data set.&amp;nbsp; The largest data set has to be read in single threaded in order for the merge to work correctly.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With my multi-threaded approach, I can get the largest data set read in 45 minutes (some times 30 if I allocate more threads).&amp;nbsp; The interleave still takes 1.5 hours.&amp;nbsp; So, we're talking about 2 to 2.5 hours with the multi-threaded approach with separate read and merge phases vs. a minimum of 4 hours with the combined read/merge in a single DATA step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SPDE remains intriguing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2018 06:03:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456147#M115513</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2018-04-21T06:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456433#M115609</link>
      <description>&lt;P&gt;One way to speed up things may be to do the reading and the interleaving in one step. In other words, instead of reading the files first, create the input steps as data step views, and then set the views:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data v1/view=v1;
  infile file1 dsd delimiter=';';
  input...
/* etc. */

data v2/view=v2;
  infile file2 dsd delimiter=';';
  input...
/* etc */

data interleaved;
  set v1 v2 v3 v4 v5 v6...;
  by num_key;
run;
 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Apr 2018 09:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456433#M115609</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-04-23T09:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456455#M115619</link>
      <description>&lt;P&gt;If you have some kind of Relational Database. I was confronted with&amp;nbsp;exactly same&amp;nbsp;issue. CSVs&amp;nbsp; ReadIns&amp;nbsp; was taking enormous amount of time 2 hours. we imported the data to Teradata warehouse and then imported data to SAS that was very quick . Significant improving was made and new import time from Teradata was&amp;nbsp;between 5 to 10 min.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2018 10:25:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456455#M115619</guid>
      <dc:creator>emrancaan</dc:creator>
      <dc:date>2018-04-23T10:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Combining multiple SAS datasets while maintaining sort order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456749#M115731</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37107"&gt;@jimbarbour&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;It looks to me that you've done already a lot of the good stuff that's available to you. One of the things you could still try is to test your I/O relevant settings and see if you can optimize them for your use case. Not sure how much you've done already and if it's even worth for you to spend the time for it. It could be interesting though.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/51/660.html&amp;nbsp;" target="_blank"&gt;http://support.sas.com/kb/51/660.html&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/46/954.html&amp;nbsp;" target="_blank"&gt;http://support.sas.com/kb/46/954.html&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 02:22:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combining-multiple-SAS-datasets-while-maintaining-sort-order/m-p/456749#M115731</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-04-24T02:22:49Z</dc:date>
    </item>
  </channel>
</rss>

