<?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: Need to Impute Demographic Data (present for one obs/person, expect it to correlated to unique I in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294599#M60080</link>
    <description>&lt;P&gt;Remove the comma after tage.&lt;/P&gt;</description>
    <pubDate>Sat, 27 Aug 2016 20:38:11 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-08-27T20:38:11Z</dc:date>
    <item>
      <title>Need to Impute Demographic Data (present for one obs/person, expect it to correlated to unique ID)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294595#M60076</link>
      <description>&lt;P&gt;Hi Sas Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I haven't come across this before, but I have multiple observations per person, and then for observations that are expected to be repeated (like sex) they are only listed once per person and then the rest are listed as missing. A way simplified version of the data is like this:&lt;/P&gt;&lt;P&gt;Person &amp;nbsp; &amp;nbsp; Sex&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;I need those variables to not be missing. I can be basically 100% certain&amp;nbsp;that that is exactly what&amp;nbsp;that person's sex will be at the next observation.&amp;nbsp;Sooooo I've read about single or deterministic regression imputation, and it sounds like that'd be&amp;nbsp;a good way to go. I haven't found any code anywhere for this though? Does anyone have any code to offer to help me go about this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Estelle&lt;/P&gt;</description>
      <pubDate>Sat, 27 Aug 2016 19:32:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294595#M60076</guid>
      <dc:creator>Estelle</dc:creator>
      <dc:date>2016-08-27T19:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Impute Demographic Data (present for one obs/person, expect it to correlated to unique I</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294597#M60078</link>
      <description>&lt;P&gt;Imputation is about replacing unknown values with probable/representative values. All you need is to replace&amp;nbsp;missing information in a deterministic way.&lt;/P&gt;
&lt;P&gt;One way to do this is to invoque SQL automatic remerging and use the fact that SAS missing values are inferior to non-missing values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Person Sex :$1. Age x;
datalines;
1    2 30 0.1
1    . . 0.2
1    .  . 0.3
2    1 32 1.1
2    . . 1.2
2    . . 1.3
;

Proc sql;
create table want as
select 
    Person, 
    max(sex) as sex,
    max(age) as age,
    x
from have
group by person;
select * from want;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 27 Aug 2016 20:05:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294597#M60078</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-08-27T20:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Impute Demographic Data (present for one obs/person, expect it to correlated to unique I</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294598#M60079</link>
      <description>&lt;P&gt;I'm a new to SQL so that's maybe a problem here. I'm submitting this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;STRONG&gt;Proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;&lt;SPAN class="s1"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;create table&lt;SPAN class="s1"&gt; imputed &lt;/SPAN&gt;as&lt;/P&gt;&lt;P class="p2"&gt;select&lt;/P&gt;&lt;P class="p3"&gt;nomen,&lt;/P&gt;&lt;P class="p3"&gt;max (sexeps) &lt;SPAN class="s2"&gt;as&lt;/SPAN&gt; sexeps,&lt;/P&gt;&lt;P class="p3"&gt;max (tage) &lt;SPAN class="s2"&gt;as&lt;/SPAN&gt; tage,&lt;/P&gt;&lt;P class="p3"&gt;&lt;SPAN class="s2"&gt;from&lt;/SPAN&gt; mergeinca2&lt;/P&gt;&lt;P class="p3"&gt;&lt;SPAN class="s2"&gt;group&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;by&lt;/SPAN&gt; nomen;&lt;/P&gt;&lt;P class="p1"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;SPAN class="s1"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;And it tells me in the log "expecting a "FROM" (and underlines "from mergeinca2"). Mergeinca2 is the relevant dataset.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Aug 2016 20:33:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294598#M60079</guid>
      <dc:creator>Estelle</dc:creator>
      <dc:date>2016-08-27T20:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Impute Demographic Data (present for one obs/person, expect it to correlated to unique I</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294599#M60080</link>
      <description>&lt;P&gt;Remove the comma after tage.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Aug 2016 20:38:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294599#M60080</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-08-27T20:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Impute Demographic Data (present for one obs/person, expect it to correlated to unique I</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294600#M60081</link>
      <description>&lt;P&gt;Remove the comma after tage.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Aug 2016 20:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294600#M60081</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-08-27T20:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Impute Demographic Data (present for one obs/person, expect it to correlated to unique I</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294601#M60082</link>
      <description>&lt;P&gt;This procedure actually omits all repeated observations (because the repeated observations are from other variables). I think I need to "keep" the other variables in my dataset while running proc sql perhaps?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am submitting this code and I think maybe my "group by" line is now in the wrong spot?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;STRONG&gt;Proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;&lt;SPAN class="s1"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p2"&gt;create table&lt;SPAN class="s1"&gt; imputed &lt;/SPAN&gt;as&lt;/P&gt;&lt;P class="p3"&gt;&lt;SPAN class="s2"&gt;select&lt;/SPAN&gt; nomen,&lt;/P&gt;&lt;P class="p3"&gt;max (sexeps) &lt;SPAN class="s2"&gt;as&lt;/SPAN&gt; sexeps2,&lt;/P&gt;&lt;P class="p3"&gt;max (tage) &lt;SPAN class="s2"&gt;as&lt;/SPAN&gt; tage2&lt;/P&gt;&lt;P class="p3"&gt;&lt;SPAN class="s2"&gt;from&lt;/SPAN&gt; mergeinca2 (keep= sexeps codgr tage qte_nette nomen qte_brute nbjcc);&lt;/P&gt;&lt;P class="p3"&gt;&lt;SPAN class="s2"&gt;group&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;by&lt;/SPAN&gt; nomen;&lt;/P&gt;&lt;P class="p1"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;SPAN class="s1"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;I get the message "Statement is not valid or used out of proper order" with group by nomen underlined in the log. Also the table has all sex set to 2 and all age categories set to 8 for all 541,526. Do I have to put that group by variable somewhere else if I want to keep other variables from the mergeinca2 dataset?&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;Estelle&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Aug 2016 21:17:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294601#M60082</guid>
      <dc:creator>Estelle</dc:creator>
      <dc:date>2016-08-27T21:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Impute Demographic Data (present for one obs/person, expect it to correlated to unique I</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294602#M60083</link>
      <description>&lt;P&gt;Try this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Remove extra semicolon&lt;/P&gt;
&lt;P&gt;2. Add * to beginning of query&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc sql;&lt;BR /&gt;create table imputed as&lt;BR /&gt;select *, nomen,&lt;BR /&gt;max (sexeps) as sexeps2,&lt;BR /&gt;max (tage) as tage2&lt;BR /&gt;from mergeinca2&amp;nbsp;&lt;BR /&gt;group by nomen;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Aug 2016 23:18:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294602#M60083</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-27T23:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Impute Demographic Data (present for one obs/person, expect it to correlated to unique I</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294603#M60084</link>
      <description>&lt;P&gt;You are very close,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
create table imputed as
select 
	nomen,
	codgr, qte_nette, qte_brute, nbjcc,
	max (sexeps) as sexeps,
	max (tage) as tage
from mergeinca2
group by nomen;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Aug 2016 00:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294603#M60084</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-08-28T00:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Impute Demographic Data (present for one obs/person, expect it to correlated to unique I</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294604#M60085</link>
      <description>&lt;PRE&gt;
data have;
input Person     Sex;
cards;
1                2
1                .
1                . 
2                1
2                .
2                .
;
run;
data want;
 merge have(drop=sex) have(keep=person sex where=(sex is not missing)) ;
 by person;
run;

&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Aug 2016 01:33:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-to-Impute-Demographic-Data-present-for-one-obs-person/m-p/294604#M60085</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-28T01:33:42Z</dc:date>
    </item>
  </channel>
</rss>

