<?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 of people per year when they have multiple years in SAS in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Count-the-number-of-people-per-year-when-they-have-multiple/m-p/818997#M34702</link>
    <description>&lt;P&gt;To count only DISTINCT patients in a given year :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table counts as
select 
    year_of_vaccine,
    count (distinct patient_id) as count
from have0
group by year_of_vaccine;
quit;

proc transpose data=counts out=want(drop=_name_);
var count;
id year_of_vaccine;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1655575650251.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72418i417AFA7E595D563C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PGStats_0-1655575650251.png" alt="PGStats_0-1655575650251.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 18 Jun 2022 18:07:47 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2022-06-18T18:07:47Z</dc:date>
    <item>
      <title>Count the number of people per year when they have multiple years in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-the-number-of-people-per-year-when-they-have-multiple/m-p/818976#M34700</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;I want to count the number of people who took a vaccine in a particular year when they have multiple years. This is what I have.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="data.PNG" style="width: 250px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72414i63CDA7A09261A04D/image-size/large?v=v2&amp;amp;px=999" role="button" title="data.PNG" alt="data.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;So if I want the number of people who took a vaccine in Year 2017, that's going to be 2, that is patient with Id L001 and L005. If a patient took two different vaccines in the same year (for eg. L002), we count it just once (I know that's obvious). This is what I want&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="want.PNG" style="width: 833px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72415i665E3963AAF4BC76/image-size/large?v=v2&amp;amp;px=999" role="button" title="want.PNG" alt="want.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thank you&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jun 2022 13:04:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-the-number-of-people-per-year-when-they-have-multiple/m-p/818976#M34700</guid>
      <dc:creator>nab102</dc:creator>
      <dc:date>2022-06-18T13:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of people per year when they have multiple years in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-the-number-of-people-per-year-when-they-have-multiple/m-p/818986#M34701</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See here :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.have0;
input patient_id $ year_of_vaccine;
cards;
L001 2017
L001 2019 
L002 2020
L002 2020 
L003 2018
L003 2019
L004 2021
L005 2017
L006 2020
L006 2021
;
run;

proc sort data=work.have0 out=work.have1 NODUPKEY;
 by patient_id year_of_vaccine;
run;

PROC FREQ data=work.have1;
 tables year_of_vaccine / out=work.want;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jun 2022 13:42:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-the-number-of-people-per-year-when-they-have-multiple/m-p/818986#M34701</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-06-18T13:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of people per year when they have multiple years in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-the-number-of-people-per-year-when-they-have-multiple/m-p/818997#M34702</link>
      <description>&lt;P&gt;To count only DISTINCT patients in a given year :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table counts as
select 
    year_of_vaccine,
    count (distinct patient_id) as count
from have0
group by year_of_vaccine;
quit;

proc transpose data=counts out=want(drop=_name_);
var count;
id year_of_vaccine;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1655575650251.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72418i417AFA7E595D563C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PGStats_0-1655575650251.png" alt="PGStats_0-1655575650251.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jun 2022 18:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-the-number-of-people-per-year-when-they-have-multiple/m-p/818997#M34702</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-06-18T18:07:47Z</dc:date>
    </item>
  </channel>
</rss>

