<?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: replacing Missing Values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468832#M119801</link>
    <description>Sure ....&lt;BR /&gt;</description>
    <pubDate>Fri, 08 Jun 2018 18:52:15 GMT</pubDate>
    <dc:creator>Savyasachi007</dc:creator>
    <dc:date>2018-06-08T18:52:15Z</dc:date>
    <item>
      <title>replacing Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468821#M119796</link>
      <description>&lt;P&gt;Hi All , I want to replace Missing values with average. As an example my data set contains variable salary Gender and age_group, i want to replace missing values of Salary with avg for That Gender(which is in Observation)and&amp;nbsp; falls in that particular Age Group.&lt;/P&gt;&lt;P&gt;I want to replace the Missing Value @ Id 8 with Avg Salary of female in Medium Age Group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Id&lt;/TD&gt;&lt;TD&gt;Age_group&lt;/TD&gt;&lt;TD&gt;Gender&lt;/TD&gt;&lt;TD&gt;Salary&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Young&lt;/TD&gt;&lt;TD&gt;M&lt;/TD&gt;&lt;TD&gt;44701&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Medium&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;41755&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;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R&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;Old&lt;/TD&gt;&lt;TD&gt;M&lt;/TD&gt;&lt;TD&gt;87914&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 08 Jun 2018 18:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468821#M119796</guid>
      <dc:creator>Savyasachi007</dc:creator>
      <dc:date>2018-06-08T18:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: replacing Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468825#M119797</link>
      <description>&lt;P&gt;do you mean this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines truncover;
input Id	Age_group : $15.	Gender $	Salary;
cards;
1	Young	M	44701
2	Medium 	F	41755
3	Old	M	37127
4	Young	F	85233
5	Medium 	M	67517
6	Old	F	99904
7	Young	M	26938
8	Medium 	F	 
9	Old	M	37583
10	Young	F	78853
11	Medium 	M	 
12	Old	F	73138
13	Young	M	29987
14	Medium 	F	33115
15	Old	M	50883
16	Young	F	 
17	Medium 	M	48555
18	Old	F	62939
19	Young	M	52488
20	Medium 	F	65333
21	Old	M	87914
;

proc sql;
create table want as
select *,sum(salary,mean(salary)*(salary=.)) as s
from have
group by gender,Age_group
order by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jun 2018 18:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468825#M119797</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-08T18:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: replacing Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468827#M119798</link>
      <description>&lt;P&gt;The previous response shows you the missing and the average value to be imputed for those missings in the next column&lt;/P&gt;&lt;P&gt;The below one replaces the original salary column&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines truncover;
input Id	Age_group : $15.	Gender $	Salary;
cards;
1	Young	M	44701
2	Medium 	F	41755
3	Old	M	37127
4	Young	F	85233
5	Medium 	M	67517
6	Old	F	99904
7	Young	M	26938
8	Medium 	F	 
9	Old	M	37583
10	Young	F	78853
11	Medium 	M	 
12	Old	F	73138
13	Young	M	29987
14	Medium 	F	33115
15	Old	M	50883
16	Young	F	 
17	Medium 	M	48555
18	Old	F	62939
19	Young	M	52488
20	Medium 	F	65333
21	Old	M	87914
;
proc sql;
create table want as
select id,Age_group,Gender,sum(salary,mean(salary)*(salary=.)) as salary
from have
group by gender,Age_group
order by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jun 2018 18:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468827#M119798</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-08T18:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: replacing Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468830#M119799</link>
      <description>It worked , thanks but unable to understand multiplication of avg value with missing , please explain.</description>
      <pubDate>Fri, 08 Jun 2018 18:47:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468830#M119799</guid>
      <dc:creator>Savyasachi007</dc:creator>
      <dc:date>2018-06-08T18:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: replacing Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468831#M119800</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214483"&gt;@Savyasachi007&lt;/a&gt;&amp;nbsp;I am about to step out for lunch with my mates. Give me 30 mins please, I will leave some notes.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 18:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468831#M119800</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-08T18:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: replacing Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468832#M119801</link>
      <description>Sure ....&lt;BR /&gt;</description>
      <pubDate>Fri, 08 Jun 2018 18:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468832#M119801</guid>
      <dc:creator>Savyasachi007</dc:creator>
      <dc:date>2018-06-08T18:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: replacing Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468841#M119803</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214483"&gt;@Savyasachi007&lt;/a&gt;&amp;nbsp; Sorry took a bit too long as I was enjoying every bite lol&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the notes:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; There are three processes that is involved in this execution a. group by as mentioned by you&amp;nbsp; b. finding the mean&amp;nbsp; c. finding the missing&amp;nbsp; and imputing the mean&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Salary=. is binary expression that results in 1 or 0 or in other words True or false. If true which is when missing in our case, results in 1 and when not missing results in 0&lt;/P&gt;&lt;P&gt;3. Once mean is calculated, i multiply the mean with the result of binary expression to make sure I have 0's for not missing to be summed(added) with existing salary and computed mean salary value *1=&lt;SPAN&gt;computed mean salary value for missing salary&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;4. so this will result in final expression of&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;0+salaryvalue(for non missing cases)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;computedmeansalaryvalue+. (for missing cases)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;5. The sum function is applied&amp;nbsp; instead of operator to ignore the missing values and the final result will have your imputed salary safely for your missing cases and original salary for non missing cases respectively&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope that helps&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards and have a nice day.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 19:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468841#M119803</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-08T19:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: replacing Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468843#M119804</link>
      <description>&lt;P&gt;Thanks A ton,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a great day.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 19:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/468843#M119804</guid>
      <dc:creator>Savyasachi007</dc:creator>
      <dc:date>2018-06-08T19:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: replacing Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/469153#M119954</link>
      <description>&lt;P&gt;Replacing missing values by the mean is called "mean imputation," You can read about &lt;A href="https://blogs.sas.com/content/iml/2017/12/04/mean-imputation-sas.html" target="_self"&gt;how to use PROC STDIZE to perform mean imputation&lt;/A&gt;---and why mean imputation is generally a bad idea, statistically speaking.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 10:06:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-Missing-Values/m-p/469153#M119954</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-06-11T10:06:01Z</dc:date>
    </item>
  </channel>
</rss>

