<?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: Imput Missing Value in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Imput-Missing-Value/m-p/377119#M3043</link>
    <description>&lt;P&gt;Your program looks fine.&amp;nbsp; If you had trouble with it, just post the log so we can see what happened.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jul 2017 20:06:35 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-07-18T20:06:35Z</dc:date>
    <item>
      <title>Imput Missing Value</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Imput-Missing-Value/m-p/377111#M3041</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS University Edition v.9.4. I am imputing missing value in my panel data and I need your help.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Below a sample data step:&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input cust_id trans_max trans_min trans_avg;
cards;
1 10 2 6
2 5 2 .
3 20 2 11
4 14 4 .
5 3 5 .&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;As you can see, the variable "trans_avg" is nothing else that the arithmetic average between the variables "trans_max" and "trans_min".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In other words "trans_avg" is equal to:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;trans_avg=(trans_max+trans_min)/2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I tell SAS to replace the missing values with the arithmetic average between trans_max and trans_min?&lt;BR /&gt;&lt;BR /&gt;I wanted to use a code as simple as the one shown below, but SAS cannot read my formula:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
set have;
if trans_avg=. then trans_avg=((trans_max+trans_min)/2);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I know this code is wrong, but I am not so good at using SAS yet. So, hopefully you can help.&lt;BR /&gt;&lt;BR /&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 19:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Imput-Missing-Value/m-p/377111#M3041</guid>
      <dc:creator>noemi_b</dc:creator>
      <dc:date>2017-07-18T19:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: Imput Missing Value</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Imput-Missing-Value/m-p/377117#M3042</link>
      <description>&lt;P&gt;When you add missing numbers with the plus (+) sign, SAS&amp;nbsp;will return a missing value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you still wish to calculate the sum and treat the missing values as zeroes, use the sum function. You wouldn't need to add the if condition, since it will calculate the average for each row.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
set have;
trans_avg=(sum(trans_max, trans_min)) / 2;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reference:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245953.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245953.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#p17j9efnrdlz0gn1d19ete4ik8sb.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#p17j9efnrdlz0gn1d19ete4ik8sb.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 20:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Imput-Missing-Value/m-p/377117#M3042</guid>
      <dc:creator>Rwon</dc:creator>
      <dc:date>2017-07-18T20:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Imput Missing Value</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Imput-Missing-Value/m-p/377119#M3043</link>
      <description>&lt;P&gt;Your program looks fine.&amp;nbsp; If you had trouble with it, just post the log so we can see what happened.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 20:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Imput-Missing-Value/m-p/377119#M3043</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-18T20:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: Imput Missing Value</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Imput-Missing-Value/m-p/377124#M3044</link>
      <description>&lt;P&gt;As long trans_max and trans_min are bot not missing values,&lt;/P&gt;
&lt;P&gt;you can use your own code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if trans_avg=. then trans_avg=(trans_max+trans_min) / 2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;only, if there is a possiblity that one of the two are missing valuae, then &amp;nbsp;using + in oreder to summarize will result in missing value,&lt;/P&gt;
&lt;P&gt;then&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/149117"&gt;@Rwon&lt;/a&gt;&amp;nbsp;is right and you better change it to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;trans_avg = sum(trans_max, trans_min) / 2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jul 2017 20:13:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Imput-Missing-Value/m-p/377124#M3044</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-18T20:13:07Z</dc:date>
    </item>
  </channel>
</rss>

