<?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 to count frequencies between multiple variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196206#M266514</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An alternative to the array:&lt;/P&gt;&lt;P&gt;proc transpose data=have out=inter;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var dx1-dx6;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;This would give you a long list of the dx variables, you can then use freq or sql counts to get the required output table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Jul 2015 08:20:31 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-07-06T08:20:31Z</dc:date>
    <item>
      <title>How to count frequencies between multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196204#M266512</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I am trying to generate a table of total count of values across multiple values (&lt;STRONG&gt;top 100 most frequent values&lt;/STRONG&gt;).&amp;nbsp; It will be a count of a couple of multiple variables. For example, this could be an example of the data:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 455px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" width="65"&gt;ID&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="65"&gt;Dx1&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="65"&gt;Dx2&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="65"&gt;Dx3&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="65"&gt;Dx4&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="65"&gt;Dx5&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="65"&gt;Dx6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" style="border-top: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;A&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;B&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;C&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;D&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" style="border-top: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;B&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;A&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;D&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" style="border-top: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;C&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;D&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;A&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" style="border-top: none;"&gt;4&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;E&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;F &lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;A&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;D&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" style="border-top: none;"&gt;5&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;G&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;B&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;C&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;D&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;E&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;F&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to tally up all values between Dx1 - Dx6, and I would like to get the following frequency table: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 195px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" width="65"&gt;Dx&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="65"&gt;Frequency &lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="65"&gt;%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" style="border-top: none;"&gt;D&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" style="border-top: none;"&gt;A &lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" style="border-top: none;"&gt;B&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" style="border-top: none;"&gt;C&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" style="border-top: none;"&gt;F&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="15" style="border-top: none;"&gt;E&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" style="border-top: none;"&gt;G&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;LW&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2015 05:28:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196204#M266512</guid>
      <dc:creator>LLW</dc:creator>
      <dc:date>2015-07-06T05:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to count frequencies between multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196205#M266513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;perhaps you could try this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data wide;&lt;/P&gt;&lt;P&gt;infile datalines missover ;&lt;/P&gt;&lt;P&gt;input ID&amp;nbsp; Dx1 $ Dx2 $ Dx3 $ Dx4 $ Dx5 $ Dx6 $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 A B C D&lt;/P&gt;&lt;P&gt;2 B A D&lt;/P&gt;&lt;P&gt;3 C D A&lt;/P&gt;&lt;P&gt;4 E F A D&lt;/P&gt;&lt;P&gt;5 G B C D E F&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA long;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SET wide;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; ARRAY adx{*} dx1-dx6 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; DO i = 1 to 6 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if missing(adx(i)) then leave;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dx = adx(i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; OUTPUT;&lt;/P&gt;&lt;P&gt;&amp;nbsp; END;&lt;/P&gt;&lt;P&gt;&amp;nbsp; END;&lt;/P&gt;&lt;P&gt;&amp;nbsp; DROP dx1 - dx6 ;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;proc freq data=long; tables dx; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2015 06:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196205#M266513</guid>
      <dc:creator>Miracle</dc:creator>
      <dc:date>2015-07-06T06:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to count frequencies between multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196206#M266514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An alternative to the array:&lt;/P&gt;&lt;P&gt;proc transpose data=have out=inter;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var dx1-dx6;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;This would give you a long list of the dx variables, you can then use freq or sql counts to get the required output table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2015 08:20:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196206#M266514</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-07-06T08:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to count frequencies between multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196207#M266515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello to both of you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for your help. Is there a way to do it without having to transpose? This is a play set, but my actual dataset is over 300,000 with over 21 columns per entry to transpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2015 18:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196207#M266515</guid>
      <dc:creator>LLW</dc:creator>
      <dc:date>2015-07-06T18:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to count frequencies between multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196208#M266516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you'll find that many of the diagnosis will be empty so transposing isn't actually much of an issue. SAS should process 1 million rows in a few seconds on a crappy system.&lt;/P&gt;&lt;P&gt;Here's a way to do it with proc freq. Run proc freq with all variables and capture that table to run a proc freq on again. The final table should be what you're after. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data wide;&lt;/P&gt;&lt;P&gt;infile datalines missover ;&lt;/P&gt;&lt;P&gt;input ID&amp;nbsp; Dx1 $ Dx2 $ Dx3 $ Dx4 $ Dx5 $ Dx6 $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 A B C D&lt;/P&gt;&lt;P&gt;2 B A D&lt;/P&gt;&lt;P&gt;3 C D A&lt;/P&gt;&lt;P&gt;4 E F A D&lt;/P&gt;&lt;P&gt;5 G B C D E F&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ods table onewayfreqs=summary1;&lt;/P&gt;&lt;P&gt;proc freq data=wide;&lt;/P&gt;&lt;P&gt;table dx:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data summary2;&lt;/P&gt;&lt;P&gt;set summary1;&lt;/P&gt;&lt;P&gt;diagnosis=coalescec(of dx1-dx6);&lt;/P&gt;&lt;P&gt;keep diagnosis frequency;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=summary2 order=freq;&lt;/P&gt;&lt;P&gt;table diagnosis/out=want;&lt;/P&gt;&lt;P&gt;weight frequency;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=want;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2015 21:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196208#M266516</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-07-06T21:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to count frequencies between multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196209#M266517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could also try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data wide;&lt;BR /&gt;infile datalines missover ;&lt;BR /&gt;input ID&amp;nbsp; Dx1 $ Dx2 $ Dx3 $ Dx4 $ Dx5 $ Dx6 $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 A B C D&lt;BR /&gt;2 B A D&lt;BR /&gt;3 C D A&lt;BR /&gt;4 E F A D&lt;BR /&gt;5 G B C D E F&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Data Want (Keep=ID Dx);&lt;BR /&gt;&amp;nbsp; Set wide;&lt;BR /&gt;&amp;nbsp; Array DA Dx:;&lt;BR /&gt;&amp;nbsp; Do over DA;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dx=DA;&lt;BR /&gt; If not Missing (Dx);&lt;BR /&gt; Output;&lt;BR /&gt;&amp;nbsp; End;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;Proc Freq Data=Want;&lt;BR /&gt; Tables Dx/NoPrint Out=Want;&lt;BR /&gt;Run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 06:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196209#M266517</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2015-07-07T06:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to count frequencies between multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196210#M266518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As mentioned above, 300,00 records is nothing.&amp;nbsp; Also factor into any approach you take what you want to do with the data later.&amp;nbsp; For instance if you want to do any further summarizing, expanding of the data etc. as the normalised form is generally easier to work with.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 10:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196210#M266518</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-07-07T10:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to count frequencies between multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196211#M266519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much to everyone for your help and for the different ways to solve this problem. Thank you again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 20:10:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-frequencies-between-multiple-variables/m-p/196211#M266519</guid>
      <dc:creator>LLW</dc:creator>
      <dc:date>2015-07-08T20:10:09Z</dc:date>
    </item>
  </channel>
</rss>

