<?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: Counting frequency by group and year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648690#M194374</link>
    <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Mon, 18 May 2020 20:34:17 GMT</pubDate>
    <dc:creator>jgreenberg321</dc:creator>
    <dc:date>2020-05-18T20:34:17Z</dc:date>
    <item>
      <title>Counting frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648450#M194248</link>
      <description>&lt;P&gt;I am working with a large dataset that contains data for many hospitals (marked by "ahaid") across several years (2010-2015). Year is marked by "pryear." Each row indicates a unique surgical visit. I am trying to calculate the number of surgical visits per hospital for each year. My goal is to output a new dataset that contains "ahaid," "pryear," and count variables for each year (count_10, count_11, count_12...). I want the count variables to represent the total number of surgical visits for that value of ahaid for the specified year. I believe I can combine do loops and "by" statements to accomplish this, but am not sure of exactly the right sequence. Can anyone help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Sun, 17 May 2020 22:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648450#M194248</guid>
      <dc:creator>jgreenberg321</dc:creator>
      <dc:date>2020-05-17T22:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Counting frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648457#M194254</link>
      <description>&lt;P&gt;Use PROC FREQ instead of do loops.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
    tables ahaid*pryear;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 18 May 2020 00:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648457#M194254</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-18T00:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Counting frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648458#M194255</link>
      <description>Thank you.&lt;BR /&gt;&lt;BR /&gt;However I need to output the frequency values as new variables (one value per ahaid per pryear). Can I do that with the proc freq approach?&lt;BR /&gt;&lt;BR /&gt;Thank you again!&lt;BR /&gt;</description>
      <pubDate>Mon, 18 May 2020 00:55:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648458#M194255</guid>
      <dc:creator>jgreenberg321</dc:creator>
      <dc:date>2020-05-18T00:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Counting frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648470#M194266</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329408"&gt;@jgreenberg321&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was playing with your challenge and I have the following idea in attach&lt;/P&gt;
&lt;DIV class="lia-attachment-file-details"&gt;
&lt;DIV class="lia-attachment-file-name"&gt;&lt;STRONG&gt;&lt;SPAN class="lia-link-navigation lia-attachment-link lia-link-disabled"&gt;sas_snippet_cs_to_jgreenberg321.sas&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CS&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 02:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648470#M194266</guid>
      <dc:creator>CarlosSpranger</dc:creator>
      <dc:date>2020-05-18T02:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Counting frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648511#M194285</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329408"&gt;@jgreenberg321&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;However I need to output the frequency values as new variables (one value per ahaid per pryear). Can I do that with the proc freq approach?&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes. Use the PROC FREQ options named LIST and OUT=&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
    tables ahaid*pryear/list out=want noprint;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 10:41:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648511#M194285</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-18T10:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Counting frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648548#M194306</link>
      <description>&lt;P&gt;Thank you! This seems to work well, though I expect the other solution proposed below would also work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To organize my results by number of cases per year, I just used a transpose statement on the output dataset, though other solutions could have been as efficient or better. Thank you all for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;&lt;STRONG&gt;freq&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;data&lt;/SPAN&gt;=have;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;table&lt;/SPAN&gt; ahaid*pryear/&lt;SPAN class="s2"&gt;list&lt;/SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;out&lt;/SPAN&gt;=want_prelim (&lt;SPAN class="s2"&gt;drop&lt;/SPAN&gt;=percent)&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;noprint&lt;/SPAN&gt;;&lt;/P&gt;&lt;P class="p2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN class="s3"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;&lt;STRONG&gt;transpose&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;data&lt;/SPAN&gt;=want_prelim &lt;SPAN class="s2"&gt;out&lt;/SPAN&gt;=want_final (&lt;SPAN class="s2"&gt;drop&lt;/SPAN&gt;=_NAME_ _LABEL_);&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;by&lt;/SPAN&gt; ahaid;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s2"&gt;id&lt;/SPAN&gt; pryear;&lt;/P&gt;&lt;P class="p2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN class="s3"&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 13:36:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648548#M194306</guid>
      <dc:creator>jgreenberg321</dc:creator>
      <dc:date>2020-05-18T13:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Counting frequency by group and year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648690#M194374</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 20:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-frequency-by-group-and-year/m-p/648690#M194374</guid>
      <dc:creator>jgreenberg321</dc:creator>
      <dc:date>2020-05-18T20:34:17Z</dc:date>
    </item>
  </channel>
</rss>

