<?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 Calculating percentage with a clause in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-percentage-with-a-clause/m-p/684418#M207397</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have variables Bp and Drug. I need to check what percentage of the patient have bp above 141 according to if they used a drug or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data have;&lt;/P&gt;&lt;P&gt;input patientn bp drug$;&lt;/P&gt;&lt;P&gt;1 100 Yes&lt;/P&gt;&lt;P&gt;2 120 No&lt;/P&gt;&lt;P&gt;3 130 Yes&lt;/P&gt;&lt;P&gt;4 140 No&lt;/P&gt;&lt;P&gt;5 150 Yes&lt;/P&gt;&lt;P&gt;6 160 Yes&lt;/P&gt;&lt;P&gt;7 170 Yes&lt;/P&gt;&lt;P&gt;8 180 No&lt;/P&gt;&lt;P&gt;9 190 Yes&lt;/P&gt;&lt;P&gt;10 140 Yes&lt;/P&gt;&lt;P&gt;11 130 No&lt;/P&gt;&lt;P&gt;12 150 Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want a table like this&lt;/P&gt;&lt;P&gt;Drug&amp;nbsp; Ptcount&amp;nbsp; Total&amp;nbsp; Percent&lt;/P&gt;&lt;P&gt;Yes&amp;nbsp; &amp;nbsp; 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 62.5%&lt;/P&gt;&lt;P&gt;No&amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I would like to compare these percentages and see if they are statistically significantly different from each other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Sep 2020 22:51:49 GMT</pubDate>
    <dc:creator>ihtishamsultan</dc:creator>
    <dc:date>2020-09-16T22:51:49Z</dc:date>
    <item>
      <title>Calculating percentage with a clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-percentage-with-a-clause/m-p/684418#M207397</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have variables Bp and Drug. I need to check what percentage of the patient have bp above 141 according to if they used a drug or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data have;&lt;/P&gt;&lt;P&gt;input patientn bp drug$;&lt;/P&gt;&lt;P&gt;1 100 Yes&lt;/P&gt;&lt;P&gt;2 120 No&lt;/P&gt;&lt;P&gt;3 130 Yes&lt;/P&gt;&lt;P&gt;4 140 No&lt;/P&gt;&lt;P&gt;5 150 Yes&lt;/P&gt;&lt;P&gt;6 160 Yes&lt;/P&gt;&lt;P&gt;7 170 Yes&lt;/P&gt;&lt;P&gt;8 180 No&lt;/P&gt;&lt;P&gt;9 190 Yes&lt;/P&gt;&lt;P&gt;10 140 Yes&lt;/P&gt;&lt;P&gt;11 130 No&lt;/P&gt;&lt;P&gt;12 150 Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want a table like this&lt;/P&gt;&lt;P&gt;Drug&amp;nbsp; Ptcount&amp;nbsp; Total&amp;nbsp; Percent&lt;/P&gt;&lt;P&gt;Yes&amp;nbsp; &amp;nbsp; 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 62.5%&lt;/P&gt;&lt;P&gt;No&amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I would like to compare these percentages and see if they are statistically significantly different from each other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 22:51:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-percentage-with-a-clause/m-p/684418#M207397</guid>
      <dc:creator>ihtishamsultan</dc:creator>
      <dc:date>2020-09-16T22:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage with a clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-percentage-with-a-clause/m-p/684420#M207399</link>
      <description>&lt;P&gt;What is PTCOUNT supposed to be?&lt;/P&gt;
&lt;P&gt;Do you want a report that people read or a dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How big is your actual data set? The tests for "significantly different" will likely be different if your sample is 12 records or 100 (or so).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 23:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-percentage-with-a-clause/m-p/684420#M207399</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-16T23:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage with a clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-percentage-with-a-clause/m-p/684422#M207400</link>
      <description>&lt;P&gt;ptcount =count of patientn where bp is &amp;gt;141.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want a report that people can read.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have about 600 values in the actual dataset but with the clause that comes down to 150.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 23:42:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-percentage-with-a-clause/m-p/684422#M207400</guid>
      <dc:creator>ihtishamsultan</dc:creator>
      <dc:date>2020-09-16T23:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage with a clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-percentage-with-a-clause/m-p/684488#M207426</link>
      <description>&lt;P&gt;Start here&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* To get the table */

proc sql;
select 
    drug,
    sum(bp&amp;gt;141) as ptCount,
    count(bp) as total,
    calculated ptCount / calculated total as percent format=percentn7.1
from have
group by drug;
quit;

/* to get tests */

data want;
set have;
if bp &amp;gt; 141 then highBp = "High"; else highBp = "Low";
run;

proc freq data=want;
tables drug*highBp / chisq noprint;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Sep 2020 16:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-percentage-with-a-clause/m-p/684488#M207426</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-09-17T16:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating percentage with a clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-percentage-with-a-clause/m-p/684556#M207471</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
input pid bp drug$;
cards;
1 100 Yes
2 120 No
3 130 Yes
4 140 No
5 150 Yes
6 160 Yes
7 170 Yes
8 180 No
9 190 Yes
10 140 Yes
11 130 No
12 150 Yes
;
proc sql;
select drug,count(distinct pid) as pcount,
       (select count(distinct pid) from have where drug=a.drug) as total,
	   calculated pcount/calculated total as percent format=percent7.2
 from have as a
  where bp&amp;gt;140
   group by drug;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Sep 2020 11:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-percentage-with-a-clause/m-p/684556#M207471</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-09-17T11:45:52Z</dc:date>
    </item>
  </channel>
</rss>

