<?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: Create a data set by grabbing the first &amp;lt;insert number&amp;gt; records from a larger one in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276094#M55293</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;for the subset of first 50,000 obs using OBS= vs the view proposed by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats﻿&lt;/a&gt;&amp;nbsp;or a new data set with 50,000 obs it will make little different if any for &amp;nbsp;each method will still read 50,000 records and stop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Jun 2016 20:21:38 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2016-06-08T20:21:38Z</dc:date>
    <item>
      <title>Create a data set by grabbing the first &lt;insert number&gt; records from a larger one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276074#M55285</link>
      <description>&lt;P&gt;Hi Everyone&lt;/P&gt;&lt;P&gt;I have a data set with about 100,000 records in it. I would like to create a smaller data set from that one that is composed of the first 50,000 records. I know I can add a sequential counter column to it and then do it that way, but I was wondering if there is a way to do this by just selecting the first 50,000 records of the larger one on the fly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 19:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276074#M55285</guid>
      <dc:creator>Paul_NYS</dc:creator>
      <dc:date>2016-06-08T19:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set by grabbing the first &lt;insert number&gt; records from a larger one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276075#M55286</link>
      <description>&lt;P&gt;Use a view:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data short / view=short;
set have;
if _n_ &amp;gt; 50000 then stop;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;proc summary data=short;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 19:26:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276075#M55286</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-08T19:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set by grabbing the first &lt;insert number&gt; records from a larger one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276076#M55287</link>
      <description>&lt;P&gt;Thanks PG. That works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 19:28:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276076#M55287</guid>
      <dc:creator>Paul_NYS</dc:creator>
      <dc:date>2016-06-08T19:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set by grabbing the first &lt;insert number&gt; records from a larger one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276084#M55290</link>
      <description>&lt;P&gt;Also note ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can subset directly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=have (obs=50000) .....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the subset is for use in multiple steps, be wary of using a view.&amp;nbsp; Your program will likely run faster if you create a data set rather than a view.&amp;nbsp; Each time a view is used, it has to re-execute the instructions within it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 19:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276084#M55290</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-08T19:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set by grabbing the first &lt;insert number&gt; records from a larger one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276094#M55293</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;for the subset of first 50,000 obs using OBS= vs the view proposed by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats﻿&lt;/a&gt;&amp;nbsp;or a new data set with 50,000 obs it will make little different if any for &amp;nbsp;each method will still read 50,000 records and stop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 20:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276094#M55293</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-06-08T20:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set by grabbing the first &lt;insert number&gt; records from a larger one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276116#M55300</link>
      <description>&lt;P&gt;Rather than try to debate the issue, I ran a test.&amp;nbsp; Granted, it's one machine and one operating system.&amp;nbsp; I tested 10,000 runs against a data set, and it took about 14 minutes.&amp;nbsp; Not wanting to wait that long, I tested only 5,000 runs against a view.&amp;nbsp; That took nearly 12 minutes (almost twice as long per run).&amp;nbsp; The test data set contained 100 variables and (originally) 100,000 observations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Each "run" was a simple step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set subset;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set viewname;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At this point, I'm still convinced that the view is slower for multiple uses.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 21:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276116#M55300</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-08T21:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set by grabbing the first &lt;insert number&gt; records from a larger one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276124#M55303</link>
      <description>&lt;P&gt;Yes&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;, there is certainly extra buffering involved in using a view. But OP's question was for an "on the fly" method, which I assume is something to be used just once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OBS= dataset option is probably the most efficient method when nothing more than limiting the number observations read is required.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 21:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276124#M55303</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-08T21:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set by grabbing the first &lt;insert number&gt; records from a larger one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276134#M55307</link>
      <description>&lt;P&gt;Yes&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;&amp;nbsp;you are correct and I didn't intend to suggest that VIEW was faster, only that for this example it won't make much difference.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options Compress=yes

NOTE: Elapsed time VIEW:             00:01:04
NOTE: Elapsed time DATA:             00:00:45

options compress=no

NOTE: Elapsed time VIEW: 00:01:13
NOTE: Elapsed time DATA: 00:00:15&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This test program attempts to remove all but reading from the test.&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;data example;
   array a[100] (1:100);
   do _n_ = 1 to 1e5;
      output;
      end;
   run;
data testv / view=testv;
   set example(obs=50000);
   run;
data testd;
   set example(obs=50000);
   run;

%macro test(n);
   %local _begin_ i;
   %let _begin_ = %sysfunc(datetime());
   options notes=0;
   %do i = 1 %to &amp;amp;n;
      data _null_;
         set testv;
         run; 
      %end;      
   options notes=1;
   %put NOTE: Elapsed time VIEW: %sysfunc(intck(seconds,&amp;amp;_begin_,%sysfunc(datetime())),TOD20);   
   %let _begin_ = %sysfunc(datetime());
   options notes=0;
   %do i = 1 %to &amp;amp;n;
      data _null_;
         set testd;
         run; 
      %end;      
   options notes=1;
   %put NOTE: Elapsed time DATA: %sysfunc(intck(seconds,&amp;amp;_begin_,%sysfunc(datetime())),TOD20);   
   %mend;
%test(250);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 23:07:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/276134#M55307</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-06-08T23:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create a data set by grabbing the first &lt;insert number&gt; records from a larger one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/277344#M55669</link>
      <description>&lt;P&gt;Yes Astounding, I actually tried this method after and it works fine as well. Going forward, this is probably what I would use.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 18:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-data-set-by-grabbing-the-first-lt-insert-number-gt/m-p/277344#M55669</guid>
      <dc:creator>Paul_NYS</dc:creator>
      <dc:date>2016-06-14T18:39:39Z</dc:date>
    </item>
  </channel>
</rss>

