<?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: Simple proc sql count function taking &amp;gt;12 hours... in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424165#M104415</link>
    <description>Well your query is somewhat resource consuming, but I suspect that you have limited memory resources available for your SAS session. Check your MEMSIZE and SORTSIZE settings. Also, look in the OS for metrics connected your SAS session vs available resources.</description>
    <pubDate>Sun, 31 Dec 2017 13:29:48 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2017-12-31T13:29:48Z</dc:date>
    <item>
      <title>Simple proc sql count function taking &gt;12 hours...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424164#M104414</link>
      <description>&lt;P&gt;I'm running a very simple code on a 4GB dataset, but it's taken over 24 hours and the output file is still at 1 KB, and SAS is still giving me the hour-glass. The log doesn't show any error -- it just doesn't output anything while hour-glassing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a hunch as to what's going on?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

create table temp.count as
select count (distinct enrolid) as ndistinct, count (enrolid) as n&lt;BR /&gt; from have;

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 31 Dec 2017 13:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424164#M104414</guid>
      <dc:creator>cdubs</dc:creator>
      <dc:date>2017-12-31T13:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc sql count function taking &gt;12 hours...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424165#M104415</link>
      <description>Well your query is somewhat resource consuming, but I suspect that you have limited memory resources available for your SAS session. Check your MEMSIZE and SORTSIZE settings. Also, look in the OS for metrics connected your SAS session vs available resources.</description>
      <pubDate>Sun, 31 Dec 2017 13:29:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424165#M104415</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-12-31T13:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc sql count function taking &gt;12 hours...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424166#M104416</link>
      <description>&lt;P&gt;I'm not sure but the following is what outputted after I used "proc options group=memory; run;" &amp;lt;-- if this is the correct way to check.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there anyway to make the above query simpler? I guess I could get rid of "count (enrolid)" b/c that's just the number of observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Group=MEMORY
 SORTSIZE=1073741824
                   Specifies the amount of memory that is available to the SORT procedure.
 SUMSIZE=0         Specifies a limit on the amount of memory that is available for data
                   summarization procedures when class variables are active.
 MAXMEMQUERY=0     Specifies the maximum amount of memory that is allocated for procedures.
 MEMBLKSZ=16777216 Specifies the memory block size for Windows memory-based libraries.
 MEMMAXSZ=2147483648
                   Specifies the maximum amount of memory to allocate for using memory-based
                   libraries.
 LOADMEMSIZE=0     Specifies a suggested amount of memory that is needed for executable
                   programs loaded by SAS.
 MEMSIZE=2147483648
                   Specifies the limit on the amount of virtual memory that can be used during
                   a SAS session.
 REALMEMSIZE=0     Specifies the amount of real memory SAS can expect to allocate&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Dec 2017 13:54:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424166#M104416</guid>
      <dc:creator>cdubs</dc:creator>
      <dc:date>2017-12-31T13:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc sql count function taking &gt;12 hours...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424168#M104418</link>
      <description>&lt;P&gt;Sorting a 4Gbyte file can take a long time.&lt;/P&gt;
&lt;P&gt;Is the dataset already sorted by ENROLID?&amp;nbsp; If so you might get better results using code like this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp.count ;
 do until(eof);
   set have(keep=enrolid) end=eof ;
   by enrolid ;
   where not missing(enrolid);
   ndistinct + first.enrolid ;
   n+1;
 end;
 keep ndistinct n ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Dec 2017 15:59:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424168#M104418</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-12-31T15:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc sql count function taking &gt;12 hours...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424182#M104429</link>
      <description>&lt;P&gt;How long does a PROC FREQ take?&lt;/P&gt;
&lt;P&gt;That can be used to get the same information.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/count_distinct_by_group.sas" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/count_distinct_by_group.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Dec 2017 20:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424182#M104429</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-31T20:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc sql count function taking &gt;12 hours...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424195#M104440</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

create table temp.count1 as
select count (distinct enrolid) as ndistinct  from have;

create table temp.count2 as
select  n(enrolid) as n from have;

quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or could use Hash Table and Data step to save some time. Here is an example for sashelp.class .&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
 set sashelp.class;
 if _n_=10 then call missing(name);
 if _n_  in (1 2) then name='Judy';
run;

data _null_;
if _n_=1 then do;
 if 0 then set 	class ;
 declare hash h();
 h.definekey('name');
 h.definedone();
end;
 set class end=last;
 if not missing(name) then do;n+1; h.ref();end;

 if last then do;
   ndistinct=h.num_items;
   putlog 'ndistinct=' ndistinct '  n=' n;
 end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jan 2018 06:43:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424195#M104440</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-01-01T06:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc sql count function taking &gt;12 hours...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424221#M104456</link>
      <description>&lt;P&gt;SQL is prone to such things (bad performance when doing implicit sorting of large datasets).&lt;/P&gt;
&lt;P&gt;Try the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort
  data=have (keep=enrolid)
  out=temp
;
by enrolid;
run;

data temp.count (keep=ndistinct n);
set temp end=done;
by enrolid;
retain
  ndistinct 0
  n 0
;
n + 1;
if first.enrolid then ndistinct + 1;
if done;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Jan 2018 18:08:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-proc-sql-count-function-taking-gt-12-hours/m-p/424221#M104456</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-01T18:08:03Z</dc:date>
    </item>
  </channel>
</rss>

