<?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 predict a missing value in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407305#M279406</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173740"&gt;@SAS666&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to predict the value of a variable using either SAS EG or Enterprise Miner. I have some missing data for the StackHeight Variable shown below. Using the Sku and Supplier I can predict what the stack height might be. How would I do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;input sku $ 1-3 Supplier $ 5-12 StackHeight 13 ;&lt;BR /&gt;datalines;&lt;BR /&gt;123 Sony 5&lt;BR /&gt;123 Sony 5&lt;BR /&gt;123 Sony&lt;BR /&gt;124 LG 4&lt;BR /&gt;124 LG 3&lt;BR /&gt;124 LG&lt;BR /&gt;124 LG 4&lt;BR /&gt;125 Toshiba 5&lt;BR /&gt;125 Toshiba 5&lt;BR /&gt;125 Toshiba&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't think this is a SAS issue at all. I think the problem is there no way to "predict" the value of a missing in this situation if all you have is the SKU and Supplier (at least as far as I understand the meaning of the word "predict"). I mean, forget SAS for a second, let's just talk concepts, how would you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173740"&gt;@SAS666&lt;/a&gt;, do such a prediction if all you had was pencil and paper???\&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would also like to state that it is easy to "fill in" a number when StackHeight is missing, but that isn't the same as a "prediction". So what do you mean?&lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2017 14:43:59 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2017-10-25T14:43:59Z</dc:date>
    <item>
      <title>How to predict a missing value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407293#M279402</link>
      <description>&lt;P&gt;I'm trying to predict the value of a variable using either SAS EG or Enterprise Miner. I have some missing data for the StackHeight Variable shown below. Using the Sku and Supplier I can predict what the stack height might be. How would I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input sku $ 1-3 Supplier $ 5-12 StackHeight 13 ;&lt;BR /&gt;datalines;&lt;BR /&gt;123 Sony 5&lt;BR /&gt;123 Sony 5&lt;BR /&gt;123 Sony&lt;BR /&gt;124 LG 4&lt;BR /&gt;124 LG 3&lt;BR /&gt;124 LG&lt;BR /&gt;124 LG 4&lt;BR /&gt;125 Toshiba 5&lt;BR /&gt;125 Toshiba 5&lt;BR /&gt;125 Toshiba&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 14:25:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407293#M279402</guid>
      <dc:creator>SAS666</dc:creator>
      <dc:date>2017-10-25T14:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to predict a missing value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407300#M279403</link>
      <description>&lt;P&gt;Do you mean:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input  StackHeight 13  @;
if  StackHeight not(missing) then 
input sku $ 1-3 Supplier $ 5-12 StackHeight 13 ;
else delete;  /* ignore lines when missing */
datalines;
123 Sony 5
123 Sony 5
123 Sony
124 LG 4
124 LG 3
124 LG
124 LG 4
125 Toshiba 5
125 Toshiba 5
125 Toshiba
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Oct 2017 14:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407300#M279403</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-10-25T14:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to predict a missing value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407302#M279404</link>
      <description>&lt;P&gt;You will get same result with:&lt;BR /&gt;data test;&lt;BR /&gt; input ... ; /* your code */&lt;BR /&gt; if missing(StackHeight ) then delete;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; .... your data ...&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 14:40:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407302#M279404</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-10-25T14:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to predict a missing value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407304#M279405</link>
      <description>&lt;P&gt;No, I want to keep the rows with the missing stack height values.&amp;nbsp; What I want to do is predict what they might be using the values that are populated for the other rows.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 14:42:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407304#M279405</guid>
      <dc:creator>SAS666</dc:creator>
      <dc:date>2017-10-25T14:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to predict a missing value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407305#M279406</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173740"&gt;@SAS666&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to predict the value of a variable using either SAS EG or Enterprise Miner. I have some missing data for the StackHeight Variable shown below. Using the Sku and Supplier I can predict what the stack height might be. How would I do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;input sku $ 1-3 Supplier $ 5-12 StackHeight 13 ;&lt;BR /&gt;datalines;&lt;BR /&gt;123 Sony 5&lt;BR /&gt;123 Sony 5&lt;BR /&gt;123 Sony&lt;BR /&gt;124 LG 4&lt;BR /&gt;124 LG 3&lt;BR /&gt;124 LG&lt;BR /&gt;124 LG 4&lt;BR /&gt;125 Toshiba 5&lt;BR /&gt;125 Toshiba 5&lt;BR /&gt;125 Toshiba&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't think this is a SAS issue at all. I think the problem is there no way to "predict" the value of a missing in this situation if all you have is the SKU and Supplier (at least as far as I understand the meaning of the word "predict"). I mean, forget SAS for a second, let's just talk concepts, how would you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173740"&gt;@SAS666&lt;/a&gt;, do such a prediction if all you had was pencil and paper???\&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would also like to state that it is easy to "fill in" a number when StackHeight is missing, but that isn't the same as a "prediction". So what do you mean?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 14:43:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407305#M279406</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-10-25T14:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to predict a missing value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407310#M279407</link>
      <description>&lt;P&gt;Well, in this case Suppliers usually use the same stack height across their products.&amp;nbsp; There are actually a few more variables I would use to make the prediction. In this case it is for TV size.&amp;nbsp; So if a TV has a sku of 123 and supplier of LG and is 50-60 inches tall, I'd look to see what LG usually stacks for TVs in that size range and then input that value. That's how i've been doing it manually.&amp;nbsp; I'm trying to figure out how to do it in SAS so I can do it on a larger scale.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in my example data I'd say the missing Sony value should be 5 and the missing LG value should be 3.75 and Toshiba would be 5.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that make sense?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 14:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407310#M279407</guid>
      <dc:creator>SAS666</dc:creator>
      <dc:date>2017-10-25T14:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to predict a missing value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407315#M279408</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;So in my example data I'd say the missing Sony value should be 5 and the missing LG value should be 3.75 and Toshiba would be 5.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It would have been very helpful to both of us if you stated this in your first post. If you say LG Value should be 3 2/3 (3.667), then I understand what you are doing and the following code ought to work. If you really meant LG value is 3.75 then I don't know how you got that.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;UNTESTED CODE&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc glm data=test;
    class sku supplier;  
    model stackheight=sku*supplier;
    output out=pred predicted=predicted;
run;
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 14:56:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407315#M279408</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-10-25T14:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to predict a missing value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407327#M279409</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173740"&gt;@SAS666&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Well, in this case Suppliers usually use the same stack height across their products.&amp;nbsp; There are actually a few more variables I would use to make the prediction. In this case it is for TV size.&amp;nbsp; So if a TV has a sku of 123 and supplier of LG&lt;STRONG&gt; and is 50-60 inches tall&lt;/STRONG&gt;,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's nothing in your sample data about height....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given what you've shown, you could consider PROC STDIZE to replace the missing with the mean for the group, or some other metric (median/max).&amp;nbsp; See an example here and check the documentation for the other options.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/cbd6bd253b4ab4828dd71d0ce3d17199" target="_blank"&gt;https://gist.github.com/statgeek/cbd6bd253b4ab4828dd71d0ce3d17199&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 15:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407327#M279409</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-25T15:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to predict a missing value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407540#M279410</link>
      <description>&lt;P&gt;For numerical values, fill in with the most popular value, i.e. the mode&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input sku $ Supplier $ StackHeight;
datalines;
123 Sony 5
123 Sony 5
123 Sony .
124 LG 4
124 LG 3
124 LG .
124 LG 4
125 Toshiba 5
125 Toshiba 5
125 Toshiba .
;

proc means data=test noprint;
where StackHeight is not missing;
by sku supplier notsorted;
var StackHeight;
output out=modes mode=mode;
run;

proc sql;
update test
set StackHeight = 
    (select mode 
     from modes 
     where sku=test.sku and supplier=test.supplier)
where StackHeight is missing;
quit; 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Oct 2017 05:29:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407540#M279410</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-10-26T05:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to predict a missing value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407541#M279411</link>
      <description>&lt;P&gt;For categorical values, you have to find the most popular value yourself:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input sku $ Supplier $ StackHeight $;
datalines;
123 Sony 5
123 Sony 5
123 Sony .
124 LG 4
124 LG 3
124 LG .
124 LG 4
125 Toshiba 5
125 Toshiba 5
125 Toshiba .
;

proc sort data=test; by sku supplier StackHeight; run;

proc sql;
create table freqs as
select sku, supplier, StackHeight, count(*) as n
from test where StackHeight is not missing
group by sku, supplier, StackHeight
order by sku, supplier, n desc;
quit;

data modes;
set freqs; by sku supplier;
if first.supplier;
drop n;
run;

proc sql;
update test
set StackHeight = 
    (select StackHeight 
     from modes 
     where sku=test.sku and supplier=test.supplier)
where StackHeight is missing;
quit; 

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Oct 2017 05:34:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-predict-a-missing-value-in-SAS/m-p/407541#M279411</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-10-26T05:34:10Z</dc:date>
    </item>
  </channel>
</rss>

