<?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 proportion of observations above a certain value within proc sql? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Count-proportion-of-observations-above-a-certain-value-within/m-p/424126#M68159</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a summary of the overall_days variable, and also giving a proportion of observations where overall_days are above 360 and 730. But the syntax doesn't seem to work quite right... wondering if there's a way around this? Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
			create table summary as
			select 	min(overall_days) as min,
					max (overall_days) as max,
					mean (overall_days) as mean,
					median (overall_days) as median

count(enrolid) where overall_days&amp;gt;730 / count(enrolid) as proportion_730,
count(enrolid) where overall_days&amp;gt;365 / count(enrolid) as proportion_365

			from temp.base;
		quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 30 Dec 2017 22:25:47 GMT</pubDate>
    <dc:creator>cdubs</dc:creator>
    <dc:date>2017-12-30T22:25:47Z</dc:date>
    <item>
      <title>Count proportion of observations above a certain value within proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-proportion-of-observations-above-a-certain-value-within/m-p/424126#M68159</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a summary of the overall_days variable, and also giving a proportion of observations where overall_days are above 360 and 730. But the syntax doesn't seem to work quite right... wondering if there's a way around this? Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
			create table summary as
			select 	min(overall_days) as min,
					max (overall_days) as max,
					mean (overall_days) as mean,
					median (overall_days) as median

count(enrolid) where overall_days&amp;gt;730 / count(enrolid) as proportion_730,
count(enrolid) where overall_days&amp;gt;365 / count(enrolid) as proportion_365

			from temp.base;
		quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Dec 2017 22:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-proportion-of-observations-above-a-certain-value-within/m-p/424126#M68159</guid>
      <dc:creator>cdubs</dc:creator>
      <dc:date>2017-12-30T22:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Count proportion of observations above a certain value within proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-proportion-of-observations-above-a-certain-value-within/m-p/424135#M68160</link>
      <description>&lt;P&gt;Yeah, you can't apply WHERE&amp;nbsp;like that within a statement. But you can use the conditional logic trick to get it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS evaluates boolean conditions to 0/1, and then you can sum the 1's to get the number you need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Overall_Days&amp;gt;730 -&amp;gt; resolves to 0/1 for each record.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Counting it would still give you the total N, but SUM would add up all the 1's.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also use a subquery and CASE statements but this seems easier IMO.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;sum(overall_days&amp;gt;730) / count(enrolid) as proportion_730&lt;/CODE&gt;&lt;/PRE&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/174079"&gt;@cdubs&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to create a summary of the overall_days variable, and also giving a proportion of observations where overall_days are above 360 and 730. But the syntax doesn't seem to work quite right... wondering if there's a way around this? Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
			create table summary as
			select 	min(overall_days) as min,
					max (overall_days) as max,
					mean (overall_days) as mean,
					median (overall_days) as median

count(enrolid) where overall_days&amp;gt;730 / count(enrolid) as proportion_730,
count(enrolid) where overall_days&amp;gt;365 / count(enrolid) as proportion_365

			from temp.base;
		quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2017 23:26:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-proportion-of-observations-above-a-certain-value-within/m-p/424135#M68160</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-30T23:26:46Z</dc:date>
    </item>
  </channel>
</rss>

