<?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: How to complete missing data with average in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384109#M91665</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Hi, As follwing , I wanna &amp;nbsp;complete the missing data , but my data is too few, so I have to use average as my method.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;As always, I am the voice of gloom and doom, but if you really have very little data and lots of missings, then of course you can do the SAS coding and make the mean appear in place of the missings, but this doesn't really get you anywhere in my opinion. The problem that you have very little data and lots of missings is not fixed, it still exists, and is simply masked by this method. At worst, in this situation, your replacing the many missings with the mean of a small number of data could be mis-leading. Impossible to know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In other words, just because you CAN program something in SAS doesn't mean you should program it.&lt;/P&gt;</description>
    <pubDate>Mon, 31 Jul 2017 01:35:40 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2017-07-31T01:35:40Z</dc:date>
    <item>
      <title>How to complete missing data with average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384097#M91659</link>
      <description>&lt;P&gt;Hi, As follwing , I wanna &amp;nbsp;complete the missing data , but my data is too few, so I have to use average as my method. My code didnt work. Thank you for any suggestion.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.have;
  infile datalines dsd truncover;
  input oftic:$6. yymm:YYMMN6. yymm_e:YYMMN6. date:YYMMN6. g:32. meanest:32. g_indavg:32.;
  format yymm YYMMN6. yymm_e YYMMN6. date YYMMN6.;
  label oftic="Official Ticker Symbol" g="g" meanest="Mean Estimate";
datalines4;
ABC,200403,200207,200212,,,
ABC,200403,200207,200303,,,
ABC,200403,200207,200306,,,
ABC,200403,200207,200309,,,
ABC,200403,200207,200312,,,
ABC,200403,200207,200403,15.21,1.03,15.21
ABC,200403,200207,200406,,,
ABC,200403,200207,200409,,,
ABC,200403,200207,200412,,,
ABC,200403,200207,200503,,,
ABC,200403,200207,200506,,,
ABC,200403,200207,200509,,,
ABC,200403,200301,200306,,,
ABC,200403,200301,200309,,,
ABC,200403,200301,200312,,,
ABC,200403,200301,200403,15.21,1.03,15.21
ABC,200403,200301,200406,,,
ABC,200403,200301,200409,,,
ABC,200403,200301,200412,,,
ABC,200403,200301,200503,,,
ABC,200403,200301,200506,,,
ABC,200403,200301,200509,,,
ABC,200403,200301,200512,,,
ABC,200403,200301,200603,,,
;;;;
data want;
set have;
if g='.' then g1=mean(g);
else g1=g;
if meanest='.' then meanest1=mean(meanest);
else meanest1=meanest;
if g_indavg='.' then g_indavg1=mean(g_indavg);
else g_indavg1=g_indavg;
by oftic yymm_e;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 30 Jul 2017 19:26:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384097#M91659</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-07-30T19:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to complete missing data with average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384099#M91661</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try proc stdize.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jul 2017 19:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384099#M91661</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2017-07-30T19:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to complete missing data with average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384100#M91662</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.have;
  infile datalines dsd truncover;
  input oftic:$6. yymm:YYMMN6. yymm_e:YYMMN6. date:YYMMN6. g:32. meanest:32. g_indavg:32.;
  format yymm YYMMN6. yymm_e YYMMN6. date YYMMN6.;
  label oftic="Official Ticker Symbol" g="g" meanest="Mean Estimate";
datalines4;
ABC,200403,200207,200212,,,
ABC,200403,200207,200303,,,
ABC,200403,200207,200306,,,
ABC,200403,200207,200309,,,
ABC,200403,200207,200312,,,
ABC,200403,200207,200403,15.21,1.03,15.21
ABC,200403,200207,200406,,,
ABC,200403,200207,200409,,,
ABC,200403,200207,200412,,,
ABC,200403,200207,200503,,,
ABC,200403,200207,200506,,,
ABC,200403,200207,200509,,,
ABC,200403,200301,200306,,,
ABC,200403,200301,200309,,,
ABC,200403,200301,200312,,,
ABC,200403,200301,200403,15.21,1.03,15.21
ABC,200403,200301,200406,,,
ABC,200403,200301,200409,,,
ABC,200403,200301,200412,,,
ABC,200403,200301,200503,,,
ABC,200403,200301,200506,,,
ABC,200403,200301,200509,,,
ABC,200403,200301,200512,,,
ABC,200403,200301,200603,,,
;;;;

proc print data=have;
  title 'Have data set from datalines';
run;

proc sql;
  create table have_means as
    select *,
           mean(g) as mean_g,
           mean(meanest) as mean_meanest,
           mean(g_indavg) as mean_g_indavg
      from have;
quit;

data want(drop=mean_:);
set have_means;
if g=. then g1=mean_g;
else g1=g;
if meanest=. then meanest1=mean_meanest;
else meanest1=meanest;
if g_indavg=. then g_indavg1=mean_g_indavg;
else g_indavg1=g_indavg;
by oftic yymm_e;
run;

proc print data=want;
  title 'After using means for missing data';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 30 Jul 2017 20:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384100#M91662</guid>
      <dc:creator>SuzanneDorinski</dc:creator>
      <dc:date>2017-07-30T20:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to complete missing data with average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384108#M91664</link>
      <description>&lt;P&gt;STDIZE as mentioned by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42042"&gt;@stat_sas&lt;/a&gt;&amp;nbsp;is the simplest way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Create sample with missing data;
data missing;
	set sashelp.class;

	if mod(_n_, 2) eq 1 then
		call missing(of _numeric_);
run;

*Display for example purposes;
title 'Original data';
proc print ;
run;

*Show mean values to check results;
title 'Mean results to check output' proc means data=missing mean;
run;

*Replace missing with mean, for ALL NUMERIC variables. If you want specific variables
add them via a VAR statement;
proc stdize out=class_mean reponly method=mean;
run;

*Diplay results for example;
title 'Final - Missing replaced with Mean';
proc print data=class_mean;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 30 Jul 2017 21:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384108#M91664</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-30T21:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to complete missing data with average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384109#M91665</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Hi, As follwing , I wanna &amp;nbsp;complete the missing data , but my data is too few, so I have to use average as my method.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;As always, I am the voice of gloom and doom, but if you really have very little data and lots of missings, then of course you can do the SAS coding and make the mean appear in place of the missings, but this doesn't really get you anywhere in my opinion. The problem that you have very little data and lots of missings is not fixed, it still exists, and is simply masked by this method. At worst, in this situation, your replacing the many missings with the mean of a small number of data could be mis-leading. Impossible to know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In other words, just because you CAN program something in SAS doesn't mean you should program it.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 01:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384109#M91665</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-31T01:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to complete missing data with average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384135#M91673</link>
      <description>&lt;P&gt;Hi Paigemiller, Right, I get your idea, also I think it unreasonable to use average. But I failed to get missing data from orginal source. Any suggestion will be appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 03:27:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384135#M91673</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-07-31T03:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to complete missing data with average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384204#M91714</link>
      <description>&lt;P&gt;Depending on how much missing data you have, this stops being a programming problem, and it essentially becomes a data quality problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If, for example, 90% of your data is missing, my advice would be to state that you have very poor data quality and you cannot come to valid conclusions from this data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But only you know exactly what's in your data, and you are the one who has to decide whether the data quality is good enough to do anything or not.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 10:41:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384204#M91714</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-31T10:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to complete missing data with average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384219#M91721</link>
      <description>&lt;P&gt;Actually, my data likes that and I am checking my code and datasets carefully. As you know, giving up is very diffcult to a researcher. Thanks a lot for your suggestion.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 11:25:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384219#M91721</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-07-31T11:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to complete missing data with average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384245#M91734</link>
      <description>&lt;P&gt;To expand on &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;'s comment, replacing missing values by the average results in variables that have smaller variances than they should. Consequently.&amp;nbsp;inferences (standard errors, p-values) will be smaller than they should be, which means that you might draw invalid conclusions from the data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Replacing missing values with a nonmissing value is called "imputation." A&amp;nbsp;statistically valid way to address missing data is through a process called multiple imputations, which is carried out in SAS by using &lt;A href="https://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_mi_overview.htm" target="_self"&gt;PROC MI and PROC MIANALYZE&lt;/A&gt;. In addition to the documentation, you might want to browse SAS conference proceedings on the topic. &amp;nbsp;Try doing an internet search for&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;"proc mi" berglund site:lexjansen.com&lt;/P&gt;
&lt;P&gt;or look at&amp;nbsp;the book &lt;A href="https://www.sas.com/store/books/categories/usage-and-reference/multiple-imputation-of-missing-data-using-sas-/prodBK_65370_en.html" target="_self"&gt;Multiple Imputation of Missing Data Using SAS&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 12:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384245#M91734</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-07-31T12:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to complete missing data with average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384380#M91773</link>
      <description>&lt;P&gt;Hi Rick, thank you so much,I will study the book.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 18:42:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-complete-missing-data-with-average/m-p/384380#M91773</guid>
      <dc:creator>lixuan</dc:creator>
      <dc:date>2017-07-31T18:42:30Z</dc:date>
    </item>
  </channel>
</rss>

