<?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: Getting summary statistics without procfreq in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/434951#M107994</link>
    <description>&lt;P&gt;all the solutions are great. But i really liked your one. Thanks.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Feb 2018 16:39:42 GMT</pubDate>
    <dc:creator>tej123</dc:creator>
    <dc:date>2018-02-07T16:39:42Z</dc:date>
    <item>
      <title>Getting summary statistics without procfreq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/433931#M107648</link>
      <description>&lt;P&gt;The dataset looks like below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;colx&amp;nbsp; &amp;nbsp; &amp;nbsp; coly&amp;nbsp; &amp;nbsp; colz&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Required output:&lt;/P&gt;&lt;P&gt;Colname&amp;nbsp; &amp;nbsp; &amp;nbsp; value&amp;nbsp; &amp;nbsp; count&lt;/P&gt;&lt;P&gt;colx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;coly&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;colz&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;colz&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a code that works perfectly fine and here is how it looks.&lt;/P&gt;&lt;P&gt;ods output onewayfreqs=outfreq;&lt;/P&gt;&lt;P&gt;proc freq data= final;&lt;/P&gt;&lt;P&gt;tables colx coly colz /nocum nofreq;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data freq;&lt;/P&gt;&lt;P&gt;retain colname column_value;&lt;/P&gt;&lt;P&gt;keep colname column_value&amp;nbsp; frequency percent;&lt;/P&gt;&lt;P&gt;set outfreq;&lt;/P&gt;&lt;P&gt;colname=scan(tables,2,' ');&lt;/P&gt;&lt;P&gt;column_Value=trim(left(vvaluex(colname)));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above code works. but i believe is not efficient. Say i have 1000 columns and running prof freq on all 1000 columns is not&amp;nbsp;&lt;/P&gt;&lt;P&gt;efficient. So is there any other efficient way with out using the proc freq that accomplishes my desired output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;colname&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Feb 2018 02:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/433931#M107648</guid>
      <dc:creator>tej123</dc:creator>
      <dc:date>2018-02-04T02:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Getting summary statistics without procfreq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/433933#M107650</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this may produce the desired output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input colx coly colz;&lt;BR /&gt;datalines;&lt;BR /&gt;0 1 0 &lt;BR /&gt;0 1 1 &lt;BR /&gt;0 1 0&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want(keep=name value);&lt;BR /&gt;set have;&lt;BR /&gt;array v(*) col:;&lt;BR /&gt;do i = 1 to dim(v);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; name=vname(v(i));&lt;BR /&gt;&amp;nbsp; &amp;nbsp;value=v(i);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;select name,value,count(*) as count from want&lt;BR /&gt;group by name, value;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Feb 2018 03:17:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/433933#M107650</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2018-02-04T03:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Getting summary statistics without procfreq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/433935#M107652</link>
      <description>&lt;P&gt;I really don't know if this would work or not, but I can't test it until Monday.&amp;nbsp; I would experiment with having PROC TABULATE create an output data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc tabulate data=have noprint out=experiment;&lt;/P&gt;
&lt;P&gt;class colx coly colz;&lt;/P&gt;
&lt;P&gt;tables colx coly colz;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might need to be tweaked, it might be tremendously successful, or it might fail miserably.&amp;nbsp; That's where I would start.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Feb 2018 03:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/433935#M107652</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-04T03:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: Getting summary statistics without procfreq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/433936#M107653</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3803"&gt;@tej123&lt;/a&gt;&amp;nbsp; I personally don't think proc freq is slowing your execution, rather your datastep.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input colx      coly    colz  ;
datalines;
0           1          0      
0           1          1      
0           1          0  
;

proc transpose data=have out=_have;
var col:;
run;

proc transpose data=_have out=_have1;
by _name_;
var col:;
run; 

proc freq data=_have1;
by _name_;
tables col1/out=want(drop=percent);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Feb 2018 04:01:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/433936#M107653</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-02-04T04:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Getting summary statistics without procfreq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/433940#M107656</link>
      <description>&lt;P&gt;As one of the other responses suggest, make a data set with NAME and VALUE.&amp;nbsp; But make a data set VIEW, not a data set FILE. Then submit it to proc summary:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data vneed (keep=name value) / view=vneed;
  set have;
  array nam {1000} $32 _temporary_;
  array v{*} col:;

  if _n_=1 then do i=1 to dim(v);
    nam{i}=vname(v{i});
  end;

  do i = 1 to dim(v);
   name=nam{i};
   value=v(i);
   output;
  end;
run;

proc summary data=vneed nway;
  class name value;
  output out=t (drop=_type_);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The data set view is not activated until called by proc summary. As a result, the data in VNEED is not written to disk, but streamed directly to proc summary.&lt;/LI&gt;
&lt;LI&gt;Make the array NAM at least as big as the array V.&lt;/LI&gt;
&lt;LI&gt;Don't repeatedly call function VNAME X times for every obs. Do it once and retrieve the resulting names from the NAM array.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sun, 04 Feb 2018 05:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/433940#M107656</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-02-04T05:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: Getting summary statistics without procfreq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/434016#M107679</link>
      <description>&lt;P&gt;I should have posted this last night, but i was too lazy&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input colx      coly    colz  ;
datalines;
0           1          0      
0           1          1      
0           1          0  
;

data _null_;
 if _N_ = 1 then do;
 	length Colname $8 count 8;
     declare hash h(ordered:'y' );
     h.defineKey('Colname','value');
     h.defineData('Colname','value','count');
     h.defineDone( );
     call missing(value, count);
   end;
set have end=last;
array t(*) colx--colz;
do n=1 to dim(t);
 Colname=vname(t(n));
 value=t(n);
 if h.check() ne 0 then do;count=1;h.add();end;
 else if h.find()=0 then do; count=count+1;h.replace();end;
end;
if last then h.output(dataset:'want');
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3803"&gt;@tej123&lt;/a&gt;&amp;nbsp; I hope you accept and mark one of anybody's response that you most prefer. The acknowledgement is what makes people like me interested to participate here. I guess it's only fair. Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Feb 2018 22:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/434016#M107679</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-02-04T22:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Getting summary statistics without procfreq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/434951#M107994</link>
      <description>&lt;P&gt;all the solutions are great. But i really liked your one. Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 16:39:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-summary-statistics-without-procfreq/m-p/434951#M107994</guid>
      <dc:creator>tej123</dc:creator>
      <dc:date>2018-02-07T16:39:42Z</dc:date>
    </item>
  </channel>
</rss>

