<?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 creating a new variable based on a frequency in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/creating-a-new-variable-based-on-a-frequency/m-p/400145#M66689</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am dealing with data where I have subject IDs and a variable that tells me the diseases each subject has. Some of the subjects have more than one disease but they are just inputted in the dataset multiple times. For example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data example;&lt;/P&gt;&lt;P&gt;input ID condition$ ;&lt;/P&gt;&lt;P&gt;datalines;&amp;nbsp;&lt;/P&gt;&lt;P&gt;45 diabetes&lt;/P&gt;&lt;P&gt;46 cancer&lt;/P&gt;&lt;P&gt;46 diabetes&amp;nbsp;&lt;/P&gt;&lt;P&gt;47 cancer&amp;nbsp;&lt;/P&gt;&lt;P&gt;;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want is a summary of the frequency of conditions. For example, X number of people have only one condition but Y number of people have two conditions and Z number of people have three conditions, etc. I am thinking that I would just like to create a variable that tells me the number of conditions each participant has but I am not sure how to do this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way I can do this?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 01 Oct 2017 17:41:35 GMT</pubDate>
    <dc:creator>c_starfish</dc:creator>
    <dc:date>2017-10-01T17:41:35Z</dc:date>
    <item>
      <title>creating a new variable based on a frequency</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/creating-a-new-variable-based-on-a-frequency/m-p/400145#M66689</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am dealing with data where I have subject IDs and a variable that tells me the diseases each subject has. Some of the subjects have more than one disease but they are just inputted in the dataset multiple times. For example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data example;&lt;/P&gt;&lt;P&gt;input ID condition$ ;&lt;/P&gt;&lt;P&gt;datalines;&amp;nbsp;&lt;/P&gt;&lt;P&gt;45 diabetes&lt;/P&gt;&lt;P&gt;46 cancer&lt;/P&gt;&lt;P&gt;46 diabetes&amp;nbsp;&lt;/P&gt;&lt;P&gt;47 cancer&amp;nbsp;&lt;/P&gt;&lt;P&gt;;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want is a summary of the frequency of conditions. For example, X number of people have only one condition but Y number of people have two conditions and Z number of people have three conditions, etc. I am thinking that I would just like to create a variable that tells me the number of conditions each participant has but I am not sure how to do this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way I can do this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 17:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/creating-a-new-variable-based-on-a-frequency/m-p/400145#M66689</guid>
      <dc:creator>c_starfish</dc:creator>
      <dc:date>2017-10-01T17:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: creating a new variable based on a frequency</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/creating-a-new-variable-based-on-a-frequency/m-p/400147#M66690</link>
      <description>&lt;P&gt;Is a patient going to have multiple diagnosis entries for the same event, ie will diabetes be there twice?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not, you can use a PROC FREQ to get the number of counts. Otherwise, you're looking to count distinct.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just posted a solution on how to count distinct items per group here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Statistical-Procedures/Count-unique-variables-associated-with-one-firm/m-p/400084" target="_blank"&gt;https://communities.sas.com/t5/SAS-Statistical-Procedures/Count-unique-variables-associated-with-one-firm/m-p/400084&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 18:01:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/creating-a-new-variable-based-on-a-frequency/m-p/400147#M66690</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-01T18:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: creating a new variable based on a frequency</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/creating-a-new-variable-based-on-a-frequency/m-p/400148#M66691</link>
      <description>&lt;P&gt;Use proc summary to get the number of conditions each patient has, then pro freq to get the required output.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=example nway;
   class id;
   output out=CondById(drop=_type_ rename=(_freq_=NumConditions));
run;


proc freq data=CondById noprint;
   tables NumConditions / out=FreqCond(drop=percent);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 18:02:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/creating-a-new-variable-based-on-a-frequency/m-p/400148#M66691</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-10-01T18:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: creating a new variable based on a frequency</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/creating-a-new-variable-based-on-a-frequency/m-p/400152#M66692</link>
      <description>&lt;P&gt;Hey thank you so much! what an easy solution to my problem. You rock!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 18:40:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/creating-a-new-variable-based-on-a-frequency/m-p/400152#M66692</guid>
      <dc:creator>c_starfish</dc:creator>
      <dc:date>2017-10-01T18:40:21Z</dc:date>
    </item>
  </channel>
</rss>

