<?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 Count by month and id in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-by-month-and-id/m-p/757543#M239135</link>
    <description>&lt;P&gt;Hello Everyone. I have this hypothetical data here. I created Total_Months column in proc sql. I have id1324 with 9 sub IDs. this ID occurs every month (Jan to June) but because of sub id it occurs 54 times in data. Other two IDs in data are showing correct Total_Months because of same Sub_ID. Can someone please help fix my code to represent total number of month my id appears ignoring sub_id. I wish to get field like Desired Column.&amp;nbsp;&amp;nbsp;Thank you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE WORK.Total_Months AS &lt;BR /&gt;SELECT DISTINCT t1.ID, &lt;BR /&gt;t1.SUB_ID,&lt;BR /&gt;t1.Month, &lt;BR /&gt;count (Month) as TOTAL_MONTHS&lt;BR /&gt;FROM WORK.MONTHS_REV t1&lt;BR /&gt;GROUP BY t1.ID&lt;BR /&gt;ORDER BY t1.ID,&lt;BR /&gt;t1.Month;&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID SUB_ID Month TOTAL_MONTHS Desired Column&lt;BR /&gt;1324 7001 202101 54 6&lt;BR /&gt;1324 7002 202101 54 6&lt;BR /&gt;1324 7003 202101 54 6:&lt;/P&gt;
&lt;P&gt;1324 7004 202101 54 6&lt;BR /&gt;1324 7005 202101 54 6&lt;BR /&gt;1324 7006 202101 54 6&lt;BR /&gt;1324 7007 202101 54 6&lt;BR /&gt;1324 7008 202101 54 6&lt;BR /&gt;1324 7009 202101 54 6&lt;BR /&gt;1324 7001 202102 54 6&lt;BR /&gt;1324 7002 202102 54 6&lt;BR /&gt;1324 7003 202102 54 6&lt;BR /&gt;1324 7004 202102 54 6&lt;BR /&gt;1324 7005 202102 54 6&lt;BR /&gt;1324 7006 202102 54 6&lt;BR /&gt;1324 7007 202102 54 6&lt;BR /&gt;1324 7008 202102 54 6&lt;BR /&gt;1324 7009 202102 54 6&lt;BR /&gt;1324 7001 202102.9628 54 6&lt;BR /&gt;1324 7002 202102.9628 54 6&lt;BR /&gt;1324 7003 202102.9628 54 6&lt;BR /&gt;1324 7004 202102.9628 54 6&lt;BR /&gt;1324 7005 202102.9628 54 6&lt;BR /&gt;1324 7006 202102.9628 54 6&lt;BR /&gt;1324 7007 202102.9628 54 6&lt;BR /&gt;1324 7008 202102.9628 54 6&lt;BR /&gt;1324 7009 202103 54 6&lt;BR /&gt;1324 7001 202104 54 6&lt;BR /&gt;1324 7002 202104 54 6&lt;BR /&gt;1324 7003 202104 54 6&lt;BR /&gt;1324 7004 202104 54 6&lt;BR /&gt;1324 7005 202104 54 6&lt;BR /&gt;1324 7006 202104 54 6&lt;BR /&gt;1324 7007 202104 54 6&lt;BR /&gt;1324 7008 202104 54 6&lt;BR /&gt;1324 7009 202104 54 6&lt;BR /&gt;1324 7001 202105 54 6&lt;BR /&gt;1324 7002 202105 54 6&lt;BR /&gt;1324 7003 202105 54 6&lt;BR /&gt;1324 7004 202105 54 6&lt;BR /&gt;1324 7005 202105 54 6&lt;BR /&gt;1324 7006 202105 54 6&lt;BR /&gt;1324 7007 202105 54 6&lt;BR /&gt;1324 7008 202105 54 6&lt;BR /&gt;1324 7009 202105 54 6&lt;BR /&gt;1324 7001 202106 54 6&lt;BR /&gt;1324 7002 202106 54 6&lt;BR /&gt;1324 7003 202106 54 6&lt;BR /&gt;1324 7004 202106 54 6&lt;BR /&gt;1324 7005 202106 54 6&lt;BR /&gt;1324 7006 202106 54 6&lt;BR /&gt;1324 7007 202106 54 6&lt;BR /&gt;1324 7008 202106 54 6&lt;BR /&gt;1324 7009 202106 54 6&lt;BR /&gt;12148 7102 202101 6 6&lt;BR /&gt;12148 7102 202102 6 6&lt;BR /&gt;12148 7102 202103 6 6&lt;BR /&gt;12148 7102 202104 6 6&lt;BR /&gt;12148 7102 202105 6 6&lt;BR /&gt;12148 7102 202106 6 6&lt;BR /&gt;1342 6686 202103 4 4&lt;BR /&gt;1342 6686 202104 4 4&lt;BR /&gt;1342 6686 202105 4 4&lt;BR /&gt;1342 6686 202106 4 4&lt;/P&gt;</description>
    <pubDate>Tue, 27 Jul 2021 22:26:50 GMT</pubDate>
    <dc:creator>sasuser_sk</dc:creator>
    <dc:date>2021-07-27T22:26:50Z</dc:date>
    <item>
      <title>Count by month and id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-by-month-and-id/m-p/757543#M239135</link>
      <description>&lt;P&gt;Hello Everyone. I have this hypothetical data here. I created Total_Months column in proc sql. I have id1324 with 9 sub IDs. this ID occurs every month (Jan to June) but because of sub id it occurs 54 times in data. Other two IDs in data are showing correct Total_Months because of same Sub_ID. Can someone please help fix my code to represent total number of month my id appears ignoring sub_id. I wish to get field like Desired Column.&amp;nbsp;&amp;nbsp;Thank you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE WORK.Total_Months AS &lt;BR /&gt;SELECT DISTINCT t1.ID, &lt;BR /&gt;t1.SUB_ID,&lt;BR /&gt;t1.Month, &lt;BR /&gt;count (Month) as TOTAL_MONTHS&lt;BR /&gt;FROM WORK.MONTHS_REV t1&lt;BR /&gt;GROUP BY t1.ID&lt;BR /&gt;ORDER BY t1.ID,&lt;BR /&gt;t1.Month;&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID SUB_ID Month TOTAL_MONTHS Desired Column&lt;BR /&gt;1324 7001 202101 54 6&lt;BR /&gt;1324 7002 202101 54 6&lt;BR /&gt;1324 7003 202101 54 6:&lt;/P&gt;
&lt;P&gt;1324 7004 202101 54 6&lt;BR /&gt;1324 7005 202101 54 6&lt;BR /&gt;1324 7006 202101 54 6&lt;BR /&gt;1324 7007 202101 54 6&lt;BR /&gt;1324 7008 202101 54 6&lt;BR /&gt;1324 7009 202101 54 6&lt;BR /&gt;1324 7001 202102 54 6&lt;BR /&gt;1324 7002 202102 54 6&lt;BR /&gt;1324 7003 202102 54 6&lt;BR /&gt;1324 7004 202102 54 6&lt;BR /&gt;1324 7005 202102 54 6&lt;BR /&gt;1324 7006 202102 54 6&lt;BR /&gt;1324 7007 202102 54 6&lt;BR /&gt;1324 7008 202102 54 6&lt;BR /&gt;1324 7009 202102 54 6&lt;BR /&gt;1324 7001 202102.9628 54 6&lt;BR /&gt;1324 7002 202102.9628 54 6&lt;BR /&gt;1324 7003 202102.9628 54 6&lt;BR /&gt;1324 7004 202102.9628 54 6&lt;BR /&gt;1324 7005 202102.9628 54 6&lt;BR /&gt;1324 7006 202102.9628 54 6&lt;BR /&gt;1324 7007 202102.9628 54 6&lt;BR /&gt;1324 7008 202102.9628 54 6&lt;BR /&gt;1324 7009 202103 54 6&lt;BR /&gt;1324 7001 202104 54 6&lt;BR /&gt;1324 7002 202104 54 6&lt;BR /&gt;1324 7003 202104 54 6&lt;BR /&gt;1324 7004 202104 54 6&lt;BR /&gt;1324 7005 202104 54 6&lt;BR /&gt;1324 7006 202104 54 6&lt;BR /&gt;1324 7007 202104 54 6&lt;BR /&gt;1324 7008 202104 54 6&lt;BR /&gt;1324 7009 202104 54 6&lt;BR /&gt;1324 7001 202105 54 6&lt;BR /&gt;1324 7002 202105 54 6&lt;BR /&gt;1324 7003 202105 54 6&lt;BR /&gt;1324 7004 202105 54 6&lt;BR /&gt;1324 7005 202105 54 6&lt;BR /&gt;1324 7006 202105 54 6&lt;BR /&gt;1324 7007 202105 54 6&lt;BR /&gt;1324 7008 202105 54 6&lt;BR /&gt;1324 7009 202105 54 6&lt;BR /&gt;1324 7001 202106 54 6&lt;BR /&gt;1324 7002 202106 54 6&lt;BR /&gt;1324 7003 202106 54 6&lt;BR /&gt;1324 7004 202106 54 6&lt;BR /&gt;1324 7005 202106 54 6&lt;BR /&gt;1324 7006 202106 54 6&lt;BR /&gt;1324 7007 202106 54 6&lt;BR /&gt;1324 7008 202106 54 6&lt;BR /&gt;1324 7009 202106 54 6&lt;BR /&gt;12148 7102 202101 6 6&lt;BR /&gt;12148 7102 202102 6 6&lt;BR /&gt;12148 7102 202103 6 6&lt;BR /&gt;12148 7102 202104 6 6&lt;BR /&gt;12148 7102 202105 6 6&lt;BR /&gt;12148 7102 202106 6 6&lt;BR /&gt;1342 6686 202103 4 4&lt;BR /&gt;1342 6686 202104 4 4&lt;BR /&gt;1342 6686 202105 4 4&lt;BR /&gt;1342 6686 202106 4 4&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 22:26:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-by-month-and-id/m-p/757543#M239135</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2021-07-27T22:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: Count by month and id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-by-month-and-id/m-p/757546#M239136</link>
      <description>You need to provide your input data....you reference BLG_MO but there's no column like that in your data.&lt;BR /&gt;Do you just need a count(distinct BLG_MO)?</description>
      <pubDate>Tue, 27 Jul 2021 22:25:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-by-month-and-id/m-p/757546#M239136</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-27T22:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Count by month and id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-by-month-and-id/m-p/757550#M239139</link>
      <description>&lt;P&gt;Thank you Reeza! Yes, Distinct was needed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 22:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-by-month-and-id/m-p/757550#M239139</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2021-07-27T22:31:21Z</dc:date>
    </item>
  </channel>
</rss>

