<?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 How to use mean to calculate missing value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-mean-to-calculate-missing-value/m-p/860054#M339772</link>
    <description>&lt;P&gt;Hi SAS Communities, I tried to use the mean to represent the missing value, but it still showed there were missing value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data elsa02(drop = a _a m);&lt;/P&gt;&lt;P&gt;_a = a;&lt;/P&gt;&lt;P&gt;do _N_ = 1 by 1 until (last.idauniq | a);&lt;BR /&gt;set elsa01(rename = drinkd = a);&lt;BR /&gt;by idauniq ;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;m = mean(_a, a);&lt;/P&gt;&lt;P&gt;do _N_ = 1 to _N_;&lt;BR /&gt;set elsa01(rename = drinkd = a);&lt;BR /&gt;drinkd = coalesce(a, m);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;444 at 935:8&lt;BR /&gt;NOTE: There were 45648 observations read from the data set WORK.ELSA01.&lt;BR /&gt;NOTE: There were 45648 observations read from the data set WORK.ELSA01.&lt;BR /&gt;NOTE: The data set WORK.ELSA02 has 45648 observations and 50 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.01 second&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Feb 2023 00:30:23 GMT</pubDate>
    <dc:creator>nwang5</dc:creator>
    <dc:date>2023-02-22T00:30:23Z</dc:date>
    <item>
      <title>How to use mean to calculate missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-mean-to-calculate-missing-value/m-p/860054#M339772</link>
      <description>&lt;P&gt;Hi SAS Communities, I tried to use the mean to represent the missing value, but it still showed there were missing value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data elsa02(drop = a _a m);&lt;/P&gt;&lt;P&gt;_a = a;&lt;/P&gt;&lt;P&gt;do _N_ = 1 by 1 until (last.idauniq | a);&lt;BR /&gt;set elsa01(rename = drinkd = a);&lt;BR /&gt;by idauniq ;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;m = mean(_a, a);&lt;/P&gt;&lt;P&gt;do _N_ = 1 to _N_;&lt;BR /&gt;set elsa01(rename = drinkd = a);&lt;BR /&gt;drinkd = coalesce(a, m);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;444 at 935:8&lt;BR /&gt;NOTE: There were 45648 observations read from the data set WORK.ELSA01.&lt;BR /&gt;NOTE: There were 45648 observations read from the data set WORK.ELSA01.&lt;BR /&gt;NOTE: The data set WORK.ELSA02 has 45648 observations and 50 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.01 second&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 00:30:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-mean-to-calculate-missing-value/m-p/860054#M339772</guid>
      <dc:creator>nwang5</dc:creator>
      <dc:date>2023-02-22T00:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to use mean to calculate missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-mean-to-calculate-missing-value/m-p/860058#M339774</link>
      <description>&lt;P&gt;It's hard to tell from your code what you are trying to do, or what mean you want to calculate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you edit your question to show some sample data (5 - 10 records made with a data step with cards statement), then run your code on that data, and describe how your results differ from the results you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like your code should run without errors.&amp;nbsp; But I can't quite tell the intent.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 02:33:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-mean-to-calculate-missing-value/m-p/860058#M339774</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-02-22T02:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to use mean to calculate missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-mean-to-calculate-missing-value/m-p/860067#M339778</link>
      <description>&lt;P&gt;Maybe all you want is :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table elsa02 as
select *,
	coalesce(drinkd, mean(drinkd)) as newDrinkd
from elsa01
group by idauniq;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;i.e. replace missing drinkd values with the mean of drinkd values in the same idauniq group.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 04:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-mean-to-calculate-missing-value/m-p/860067#M339778</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2023-02-22T04:53:40Z</dc:date>
    </item>
  </channel>
</rss>

