<?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: How can I get mode of row? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834067#M35833</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can transpose, such that you need to find the mode (modus) for each column.&lt;BR /&gt;You can then do that with PROC&amp;nbsp;&lt;SPAN&gt;FREQTAB, which is the CAS-enabled version of PROC FREQ.&lt;BR /&gt;&lt;BR /&gt;But with 40 billion columns you might run into problems (??).&lt;BR /&gt;With respect to "SAS: what is maximum number of columns in dataset" --&amp;gt; For all practical purposes, the answer to this question is "unlimited". But that's theory. You will probably need to split into several datasets.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Koen&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Sep 2022 11:55:33 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2022-09-19T11:55:33Z</dc:date>
    <item>
      <title>How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834049#M35830</link>
      <description>&lt;P&gt;I'm working with over 40 billion rows and 31 columns&lt;/P&gt;&lt;P&gt;and I want to check modes of each rows but I have no idea how to do it..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;A&amp;nbsp; &amp;nbsp;B C&amp;nbsp; D&amp;nbsp; E&amp;nbsp; mode&lt;/P&gt;&lt;P&gt;ㅇ ㅇ ㅇ ㅁ ㅁ&amp;nbsp; &amp;nbsp;ㅇ&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 07:16:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834049#M35830</guid>
      <dc:creator>jorheej</dc:creator>
      <dc:date>2022-09-19T07:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834057#M35832</link>
      <description>&lt;P&gt;Perhaps a hash-table approach like this answer:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Calculate-mode-for-each-row/td-p/468952" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Calculate-mode-for-each-row/td-p/468952&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 10:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834057#M35832</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-09-19T10:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834067#M35833</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can transpose, such that you need to find the mode (modus) for each column.&lt;BR /&gt;You can then do that with PROC&amp;nbsp;&lt;SPAN&gt;FREQTAB, which is the CAS-enabled version of PROC FREQ.&lt;BR /&gt;&lt;BR /&gt;But with 40 billion columns you might run into problems (??).&lt;BR /&gt;With respect to "SAS: what is maximum number of columns in dataset" --&amp;gt; For all practical purposes, the answer to this question is "unlimited". But that's theory. You will probably need to split into several datasets.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Koen&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 11:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834067#M35833</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-09-19T11:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834069#M35834</link>
      <description>&lt;P&gt;Yeah, 40B transposing 30 columns is .. a lot.&amp;nbsp; : )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/434240"&gt;@jorheej&lt;/a&gt;&amp;nbsp;, what is the range of each column, and are they integers?&amp;nbsp; Depending on the range, you might be able to calculate the mode with an array, rather than a hash table.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 12:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834069#M35834</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-09-19T12:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834073#M35835</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a b c d e f;
cards;
1 2 3 4 5 6
2 2 1 1 1 1
4 5 6 7 8 8
1 1 2 2 2 2
;

data want;
if _n_=1 then do;
length key count 8;
  declare hash h();
  declare hiter hi('h');
  h.definekey('key');
  h.definedata('key','count');
  h.definedone();
end;
set have;
array x{*}  a b c d e f;
h.clear();max=.;
do i=1 to dim(x);
  if not missing(x{i}) then do;
    key=x{i};
 if h.find()=0 then count=count+1;
  else count=1;
 h.replace();
  end;
end;
do while(hi.next()=0);
 if count&amp;gt;max then do;max=count;mode=key;end;
end;
drop i max key count;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;BTW, If you have SAS/IML ,that could be more succinct .&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; would love to IML code.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 12:15:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834073#M35835</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-09-19T12:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834171#M35844</link>
      <description>&lt;P&gt;Are the variables numeric or character or a mix?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 20:16:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834171#M35844</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-19T20:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834230#M35849</link>
      <description>It works for me. Thank you!</description>
      <pubDate>Tue, 20 Sep 2022 08:22:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834230#M35849</guid>
      <dc:creator>jorheej</dc:creator>
      <dc:date>2022-09-20T08:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834231#M35850</link>
      <description>Unfortunately, this dataset is not appropriate to use transpose but I'll remember the process of your comment &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;BR /&gt;Thank you for your reply.</description>
      <pubDate>Tue, 20 Sep 2022 08:25:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834231#M35850</guid>
      <dc:creator>jorheej</dc:creator>
      <dc:date>2022-09-20T08:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834233#M35851</link>
      <description>they are integers and the range is from 0 to 5,000,000(approximately).&lt;BR /&gt;I guess the links above uses both hash table and array and it works!&lt;BR /&gt;Thank you for your reply</description>
      <pubDate>Tue, 20 Sep 2022 08:29:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834233#M35851</guid>
      <dc:creator>jorheej</dc:creator>
      <dc:date>2022-09-20T08:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834235#M35852</link>
      <description>Hi, thank you so much and I guess the one I tried according to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt; is also your solution.&lt;BR /&gt;that one works perfectly but it doesn't.&lt;BR /&gt;Error was occurred and it says It has to be data or something in statement max=.;&lt;BR /&gt;&lt;BR /&gt;set have;&lt;BR /&gt;array x{*} a b c d e f;&lt;BR /&gt;h.clear();max=.; &amp;lt;- here&lt;BR /&gt;&lt;BR /&gt;What do you think that I've done wrong?</description>
      <pubDate>Tue, 20 Sep 2022 08:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834235#M35852</guid>
      <dc:creator>jorheej</dc:creator>
      <dc:date>2022-09-20T08:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834236#M35853</link>
      <description>Some of variables are character but I wanted to use numeric ones only for calculate mode!</description>
      <pubDate>Tue, 20 Sep 2022 08:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834236#M35853</guid>
      <dc:creator>jorheej</dc:creator>
      <dc:date>2022-09-20T08:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834254#M35854</link>
      <description>&lt;P&gt;I don't see how this bit:&lt;/P&gt;
&lt;PRE&gt;h.clear();
max=.;&lt;/PRE&gt;
&lt;P&gt;Cojuld cause an error, unless you have a character variable named MAX in your input data, and it is character, and you have the undocumented option dsoptions=Note2Err turned on.&amp;nbsp; Which seems unlikely.&lt;/P&gt;
&lt;P&gt;Can you post the log from running this step, showing all the code in the step and the error message?&lt;/P&gt;
&lt;P&gt;And when you post the log, please click the &amp;lt;/&amp;gt; button above the message box. It says "insert code" when you hover, but it's good for inserting any fixed fpnt.&amp;nbsp; It makes it easier to read.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 10:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834254#M35854</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-09-20T10:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834267#M35855</link>
      <description>Can you post your real dataset ? so I can test it .&lt;BR /&gt;And also can you post FULL log .</description>
      <pubDate>Tue, 20 Sep 2022 11:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834267#M35855</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-09-20T11:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834421#M35873</link>
      <description>&lt;PRE&gt;oh i didn't know this function :D&lt;/PRE&gt;&lt;P&gt;Thank you so much. It turns out I made mistype at the line above.&lt;/P&gt;&lt;P&gt;N0ow those codes work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a nice day !&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 05:20:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834421#M35873</guid>
      <dc:creator>jorheej</dc:creator>
      <dc:date>2022-09-21T05:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get mode of row?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834422#M35874</link>
      <description>Sorry for that, the codes were right and I mistyped that ^^;;&lt;BR /&gt;Thank you so much for your solutions, I hope you have a great day</description>
      <pubDate>Wed, 21 Sep 2022 05:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-get-mode-of-row/m-p/834422#M35874</guid>
      <dc:creator>jorheej</dc:creator>
      <dc:date>2022-09-21T05:22:38Z</dc:date>
    </item>
  </channel>
</rss>

