<?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: Calculate mean using proc sql and case when in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-mean-using-proc-sql-and-case-when/m-p/397005#M95917</link>
    <description>&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Sep 2017 03:50:32 GMT</pubDate>
    <dc:creator>gzr2mz39</dc:creator>
    <dc:date>2017-09-19T03:50:32Z</dc:date>
    <item>
      <title>Calculate mean using proc sql and case when</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-mean-using-proc-sql-and-case-when/m-p/396468#M95722</link>
      <description>&lt;P&gt;I would like to find two means of a field called close_diff.&lt;BR /&gt;close_diff has some missing values.&lt;BR /&gt;One mean (mean_ca_close_diff) is conditional on incident_with_ca=1 and action (character field) not equal to missing.&lt;BR /&gt;The other (mean_noca_close_diff) mean is conditional on incident_with_ca=1 and action (character field) equal to missing.&lt;BR /&gt;The two means calculated using the code below are the same, however, they shouldn't be.&lt;BR /&gt;Any idea how to fix this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table EE_1 as&lt;BR /&gt;select *,&lt;BR /&gt;case when (incident_with_ca=1 and action ne "")&lt;BR /&gt;then mean(close_diff) else . end as mean_ca_close_diff,&lt;BR /&gt;case when (incident_with_ca=1 and action = "")&lt;BR /&gt;then mean(close_diff) else . end as mean_noca_close_diff&lt;BR /&gt;from EE&lt;BR /&gt;group by INJURY_YEAR&lt;BR /&gt;order by EHS_ID&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 20:16:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-mean-using-proc-sql-and-case-when/m-p/396468#M95722</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2017-09-15T20:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate mean using proc sql and case when</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-mean-using-proc-sql-and-case-when/m-p/396476#M95723</link>
      <description>Case when syntax is not correct.</description>
      <pubDate>Fri, 15 Sep 2017 20:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-mean-using-proc-sql-and-case-when/m-p/396476#M95723</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2017-09-15T20:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate mean using proc sql and case when</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-mean-using-proc-sql-and-case-when/m-p/396480#M95726</link>
      <description>&lt;P&gt;OK, how should I fix the syntax?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 20:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-mean-using-proc-sql-and-case-when/m-p/396480#M95726</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2017-09-15T20:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate mean using proc sql and case when</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-mean-using-proc-sql-and-case-when/m-p/396484#M95730</link>
      <description>I will post when I get home.</description>
      <pubDate>Fri, 15 Sep 2017 20:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-mean-using-proc-sql-and-case-when/m-p/396484#M95730</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2017-09-15T20:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate mean using proc sql and case when</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-mean-using-proc-sql-and-case-when/m-p/396500#M95742</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table EE_1 as
		select *,
	
		mean(case 
				when incident_with_ca=1 and action ne ""
				then close_diff else . 
			 end) as mean_ca_close_diff,
	
		mean(case 
				when incident_with_ca=1 and action = ""
				then close_diff else . 
			end) as mean_noca_close_diff
	from EE
		group by INJURY_YEAR
			order by EHS_ID
	;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Sep 2017 21:44:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-mean-using-proc-sql-and-case-when/m-p/396500#M95742</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2017-09-15T21:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate mean using proc sql and case when</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-mean-using-proc-sql-and-case-when/m-p/397005#M95917</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 03:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-mean-using-proc-sql-and-case-when/m-p/397005#M95917</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2017-09-19T03:50:32Z</dc:date>
    </item>
  </channel>
</rss>

