<?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: count the number per month during 15 years in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/count-the-number-per-month-during-15-years/m-p/489084#M127589</link>
    <description>&lt;P&gt;What about the PROC FREQ suggested in a previous thread, did that work for you?&lt;/P&gt;
&lt;P&gt;If so, can you figure out how this could be modified to fit that form?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194466"&gt;@France&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to count the number of granted and non-granted 'DOCDB_FAMILY_ID' per 'psn_name' per month from 1990 to 2015. At the moment, I only type the code to count the number per month in 1990. I guess I need to use macro&amp;nbsp;function, but I really have no idea about how to use it.&amp;nbsp;Could you please give some suggestion to run them efficiently?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
create table step1.number_of_application as
select
co.psn_name,
count(distinct(case when earliest_filing_year = &lt;STRONG&gt;1990&lt;/STRONG&gt; and month=&lt;STRONG&gt;1&lt;/STRONG&gt; then DOCDB_FAMILY_ID end)) as application_&lt;STRONG&gt;199001&lt;/STRONG&gt;,
count(distinct(case when earliest_filing_year = &lt;STRONG&gt;1990&lt;/STRONG&gt; and month=&lt;STRONG&gt;1&lt;/STRONG&gt; and granted= 1 then DOCDB_FAMILY_ID end)) as granted_&lt;STRONG&gt;199001&lt;/STRONG&gt;,
count(distinct(case when earliest_filing_year = 1990 and month=2 then DOCDB_FAMILY_ID end)) as application_199002,
count(distinct(case when earliest_filing_year = 1990 and month=2 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199002,
count(distinct(case when earliest_filing_year = 1990 and month=3 then DOCDB_FAMILY_ID end)) as application_199003,
count(distinct(case when earliest_filing_year = 1990 and month=3 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199003,
count(distinct(case when earliest_filing_year = 1990 and month=4 then DOCDB_FAMILY_ID end)) as application_199004,
count(distinct(case when earliest_filing_year = 1990 and month=4 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199004,
count(distinct(case when earliest_filing_year = 1990 and month=5 then DOCDB_FAMILY_ID end)) as application_199005,
count(distinct(case when earliest_filing_year = 1990 and month=5 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199005,
count(distinct(case when earliest_filing_year = 1990 and month=6 then DOCDB_FAMILY_ID end)) as application_199006,
count(distinct(case when earliest_filing_year = 1990 and month=6 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199006,
count(distinct(case when earliest_filing_year = 1990 and month=7 then DOCDB_FAMILY_ID end)) as application_199007,
count(distinct(case when earliest_filing_year = 1990 and month=7 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199007,
count(distinct(case when earliest_filing_year = 1990 and month=8 then DOCDB_FAMILY_ID end)) as application_199008,
count(distinct(case when earliest_filing_year = 1990 and month=8 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199008,
count(distinct(case when earliest_filing_year = 1990 and month=9 then DOCDB_FAMILY_ID end)) as application_199009,
count(distinct(case when earliest_filing_year = 1990 and month=9 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199009,
count(distinct(case when earliest_filing_year = 1990 and month=10 then DOCDB_FAMILY_ID end)) as application_199010,
count(distinct(case when earliest_filing_year = 1990 and month=10 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199010,
count(distinct(case when earliest_filing_year = 1990 and month=11 then DOCDB_FAMILY_ID end)) as application_199011,
count(distinct(case when earliest_filing_year = 1990 and month=11 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199011,
count(distinct(case when earliest_filing_year = 1990 and month=12 then DOCDB_FAMILY_ID end)) as application_199012,
count(distinct(case when earliest_filing_year = 1990 and month=12 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199012
from Sample.applications as ap
join Sample.personapplication as pe on ap.appln_id = pe.appln_id
join Sample.companies as co on pe.person_id = co.person_id
where applt_seq_nr &amp;gt; 0
and ap.ipr_type = 'PI'
group by psn_name
order by psn_name
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;many thanks in advance,&lt;/P&gt;
&lt;P&gt;best regards&lt;/P&gt;
&lt;P&gt;France&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Aug 2018 22:41:39 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-08-22T22:41:39Z</dc:date>
    <item>
      <title>count the number per month during 15 years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-the-number-per-month-during-15-years/m-p/489082#M127588</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to count the number of granted and non-granted 'DOCDB_FAMILY_ID' per 'psn_name' per month from 1990 to 2015. At the moment, I only type the code to count the number per month in 1990. I guess I need to use macro&amp;nbsp;function, but I really have no idea about how to use it.&amp;nbsp;Could you please give some suggestion to run them efficiently?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
create table step1.number_of_application as
select
co.psn_name,
count(distinct(case when earliest_filing_year = &lt;STRONG&gt;1990&lt;/STRONG&gt; and month=&lt;STRONG&gt;1&lt;/STRONG&gt; then DOCDB_FAMILY_ID end)) as application_&lt;STRONG&gt;199001&lt;/STRONG&gt;,
count(distinct(case when earliest_filing_year = &lt;STRONG&gt;1990&lt;/STRONG&gt; and month=&lt;STRONG&gt;1&lt;/STRONG&gt; and granted= 1 then DOCDB_FAMILY_ID end)) as granted_&lt;STRONG&gt;199001&lt;/STRONG&gt;,
count(distinct(case when earliest_filing_year = 1990 and month=2 then DOCDB_FAMILY_ID end)) as application_199002,
count(distinct(case when earliest_filing_year = 1990 and month=2 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199002,
count(distinct(case when earliest_filing_year = 1990 and month=3 then DOCDB_FAMILY_ID end)) as application_199003,
count(distinct(case when earliest_filing_year = 1990 and month=3 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199003,
count(distinct(case when earliest_filing_year = 1990 and month=4 then DOCDB_FAMILY_ID end)) as application_199004,
count(distinct(case when earliest_filing_year = 1990 and month=4 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199004,
count(distinct(case when earliest_filing_year = 1990 and month=5 then DOCDB_FAMILY_ID end)) as application_199005,
count(distinct(case when earliest_filing_year = 1990 and month=5 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199005,
count(distinct(case when earliest_filing_year = 1990 and month=6 then DOCDB_FAMILY_ID end)) as application_199006,
count(distinct(case when earliest_filing_year = 1990 and month=6 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199006,
count(distinct(case when earliest_filing_year = 1990 and month=7 then DOCDB_FAMILY_ID end)) as application_199007,
count(distinct(case when earliest_filing_year = 1990 and month=7 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199007,
count(distinct(case when earliest_filing_year = 1990 and month=8 then DOCDB_FAMILY_ID end)) as application_199008,
count(distinct(case when earliest_filing_year = 1990 and month=8 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199008,
count(distinct(case when earliest_filing_year = 1990 and month=9 then DOCDB_FAMILY_ID end)) as application_199009,
count(distinct(case when earliest_filing_year = 1990 and month=9 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199009,
count(distinct(case when earliest_filing_year = 1990 and month=10 then DOCDB_FAMILY_ID end)) as application_199010,
count(distinct(case when earliest_filing_year = 1990 and month=10 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199010,
count(distinct(case when earliest_filing_year = 1990 and month=11 then DOCDB_FAMILY_ID end)) as application_199011,
count(distinct(case when earliest_filing_year = 1990 and month=11 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199011,
count(distinct(case when earliest_filing_year = 1990 and month=12 then DOCDB_FAMILY_ID end)) as application_199012,
count(distinct(case when earliest_filing_year = 1990 and month=12 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199012
from Sample.applications as ap
join Sample.personapplication as pe on ap.appln_id = pe.appln_id
join Sample.companies as co on pe.person_id = co.person_id
where applt_seq_nr &amp;gt; 0
and ap.ipr_type = 'PI'
group by psn_name
order by psn_name
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;many thanks in advance,&lt;/P&gt;&lt;P&gt;best regards&lt;/P&gt;&lt;P&gt;France&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 22:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-the-number-per-month-during-15-years/m-p/489082#M127588</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-08-22T22:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: count the number per month during 15 years</title>
      <link>https://communities.sas.com/t5/SAS-Programming/count-the-number-per-month-during-15-years/m-p/489084#M127589</link>
      <description>&lt;P&gt;What about the PROC FREQ suggested in a previous thread, did that work for you?&lt;/P&gt;
&lt;P&gt;If so, can you figure out how this could be modified to fit that form?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194466"&gt;@France&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to count the number of granted and non-granted 'DOCDB_FAMILY_ID' per 'psn_name' per month from 1990 to 2015. At the moment, I only type the code to count the number per month in 1990. I guess I need to use macro&amp;nbsp;function, but I really have no idea about how to use it.&amp;nbsp;Could you please give some suggestion to run them efficiently?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
create table step1.number_of_application as
select
co.psn_name,
count(distinct(case when earliest_filing_year = &lt;STRONG&gt;1990&lt;/STRONG&gt; and month=&lt;STRONG&gt;1&lt;/STRONG&gt; then DOCDB_FAMILY_ID end)) as application_&lt;STRONG&gt;199001&lt;/STRONG&gt;,
count(distinct(case when earliest_filing_year = &lt;STRONG&gt;1990&lt;/STRONG&gt; and month=&lt;STRONG&gt;1&lt;/STRONG&gt; and granted= 1 then DOCDB_FAMILY_ID end)) as granted_&lt;STRONG&gt;199001&lt;/STRONG&gt;,
count(distinct(case when earliest_filing_year = 1990 and month=2 then DOCDB_FAMILY_ID end)) as application_199002,
count(distinct(case when earliest_filing_year = 1990 and month=2 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199002,
count(distinct(case when earliest_filing_year = 1990 and month=3 then DOCDB_FAMILY_ID end)) as application_199003,
count(distinct(case when earliest_filing_year = 1990 and month=3 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199003,
count(distinct(case when earliest_filing_year = 1990 and month=4 then DOCDB_FAMILY_ID end)) as application_199004,
count(distinct(case when earliest_filing_year = 1990 and month=4 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199004,
count(distinct(case when earliest_filing_year = 1990 and month=5 then DOCDB_FAMILY_ID end)) as application_199005,
count(distinct(case when earliest_filing_year = 1990 and month=5 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199005,
count(distinct(case when earliest_filing_year = 1990 and month=6 then DOCDB_FAMILY_ID end)) as application_199006,
count(distinct(case when earliest_filing_year = 1990 and month=6 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199006,
count(distinct(case when earliest_filing_year = 1990 and month=7 then DOCDB_FAMILY_ID end)) as application_199007,
count(distinct(case when earliest_filing_year = 1990 and month=7 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199007,
count(distinct(case when earliest_filing_year = 1990 and month=8 then DOCDB_FAMILY_ID end)) as application_199008,
count(distinct(case when earliest_filing_year = 1990 and month=8 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199008,
count(distinct(case when earliest_filing_year = 1990 and month=9 then DOCDB_FAMILY_ID end)) as application_199009,
count(distinct(case when earliest_filing_year = 1990 and month=9 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199009,
count(distinct(case when earliest_filing_year = 1990 and month=10 then DOCDB_FAMILY_ID end)) as application_199010,
count(distinct(case when earliest_filing_year = 1990 and month=10 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199010,
count(distinct(case when earliest_filing_year = 1990 and month=11 then DOCDB_FAMILY_ID end)) as application_199011,
count(distinct(case when earliest_filing_year = 1990 and month=11 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199011,
count(distinct(case when earliest_filing_year = 1990 and month=12 then DOCDB_FAMILY_ID end)) as application_199012,
count(distinct(case when earliest_filing_year = 1990 and month=12 and granted= 1 then DOCDB_FAMILY_ID end)) as granted_199012
from Sample.applications as ap
join Sample.personapplication as pe on ap.appln_id = pe.appln_id
join Sample.companies as co on pe.person_id = co.person_id
where applt_seq_nr &amp;gt; 0
and ap.ipr_type = 'PI'
group by psn_name
order by psn_name
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;many thanks in advance,&lt;/P&gt;
&lt;P&gt;best regards&lt;/P&gt;
&lt;P&gt;France&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 22:41:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/count-the-number-per-month-during-15-years/m-p/489084#M127589</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-22T22:41:39Z</dc:date>
    </item>
  </channel>
</rss>

