<?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 replace missing values within household level data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12531#M1374</link>
    <description>Seems like you can just merge on the income variables after renaming.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data survey;&lt;BR /&gt;
   infile cards missover;&lt;BR /&gt;
   input houseid:$4. subjectid:$5. hhincome hhtype;&lt;BR /&gt;
   cards;&lt;BR /&gt;
1001 10011 10000 2&lt;BR /&gt;
1001 10012 &lt;BR /&gt;
1002 10021 &lt;BR /&gt;
1002 10022 25000 3&lt;BR /&gt;
;;;;&lt;BR /&gt;
&lt;BR /&gt;
data surver2;&lt;BR /&gt;
   merge &lt;BR /&gt;
      survey &lt;BR /&gt;
      survey&lt;BR /&gt;
         (&lt;BR /&gt;
            keep=houseid hh: &lt;BR /&gt;
            rename=(hhincome=income hhtype=type)&lt;BR /&gt;
            where=(not missing(income))&lt;BR /&gt;
         )&lt;BR /&gt;
      ;&lt;BR /&gt;
   by houseid;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
Obs    houseid    subjectid    hhincome    hhtype    income    type&lt;BR /&gt;
&lt;BR /&gt;
 1      1001        10011        10000        2       10000      2&lt;BR /&gt;
 2      1001        10012            .        .       10000      2&lt;BR /&gt;
 3      1002        10021            .        .       25000      3&lt;BR /&gt;
 4      1002        10022        25000        3       25000      3&lt;BR /&gt;
[/pre]</description>
    <pubDate>Fri, 18 Feb 2011 23:21:14 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2011-02-18T23:21:14Z</dc:date>
    <item>
      <title>How to replace missing values within household level data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12526#M1369</link>
      <description>I have a dataset where individual subjects are uniquely identified by SUBJECTID. Each subject belongs to a household which is identified by the variable HOUSEID. There can be 1 or 2 subjects in each household. We asked a subset of questions ONLY of one member of the household. For subjects in the household who were not asked this series of questions, they currently have missing values for those particular variables in the dataset. I would like to input the other household member’s response in for these missing responses, and I would like this information to be created as a new variable (because I would like to keep the original variables intact). I would also like the original value for the respondent to be carried over into the new variable as well. &lt;BR /&gt;
&lt;BR /&gt;
Briefly, here's what the data look like:&lt;BR /&gt;
data temp;&lt;BR /&gt;
   input houseid subjectid hhincome hhtype;&lt;BR /&gt;
   datalines;                      &lt;BR /&gt;
1001   10011   10000   2&lt;BR /&gt;
1001   10012&lt;BR /&gt;
1002   10021&lt;BR /&gt;
1002   10022   25000   3&lt;BR /&gt;
;</description>
      <pubDate>Thu, 17 Feb 2011 21:43:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12526#M1369</guid>
      <dc:creator>Tamara_UCD</dc:creator>
      <dc:date>2011-02-17T21:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace missing values within household level data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12527#M1370</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I hope that I understood your particular requirements and this will help.&lt;BR /&gt;
--&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
	input houseid subjectid hhincome hhtype;&lt;BR /&gt;
	datalines;&lt;BR /&gt;
		1001 10011 10000 2&lt;BR /&gt;
		1001 10012 . .&lt;BR /&gt;
		1002 10021 . .  &lt;BR /&gt;
		1002 10022 25000 3&lt;BR /&gt;
; &lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=temp out=temp2;&lt;BR /&gt;
	by houseid descending hhincome;		&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data temp3;&lt;BR /&gt;
	set temp2;&lt;BR /&gt;
	 by houseid;&lt;BR /&gt;
	retain hhincome2 0;&lt;BR /&gt;
	retain hhtype2 0;&lt;BR /&gt;
	if first.houseid=1 then&lt;BR /&gt;
	  do;&lt;BR /&gt;
		hhincome2=hhincome;&lt;BR /&gt;
		hhtype2=hhtype;&lt;BR /&gt;
	  end;&lt;BR /&gt;
	output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Warm regards,&lt;BR /&gt;
Vasile</description>
      <pubDate>Fri, 18 Feb 2011 01:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12527#M1370</guid>
      <dc:creator>Vasile01</dc:creator>
      <dc:date>2011-02-18T01:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace missing values within household level data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12528#M1371</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
here is another solution which will update all variables of the second household  subject (except  subjectid) with the values of the first subject :&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data x;&lt;BR /&gt;
&lt;BR /&gt;
if first.houseid and ^missing(houseid) then link build;&lt;BR /&gt;
&lt;BR /&gt;
set temp;&lt;BR /&gt;
by houseid ;&lt;BR /&gt;
&lt;BR /&gt;
if first.houseid then output;&lt;BR /&gt;
return;&lt;BR /&gt;
&lt;BR /&gt;
build: 	&lt;BR /&gt;
set temp(keep=subjectid) point=_n_;&lt;BR /&gt;
output;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Marius</description>
      <pubDate>Fri, 18 Feb 2011 16:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12528#M1371</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-18T16:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace missing values within household level data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12529#M1372</link>
      <description>Do not forget about the sorting as I did &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sort data=temp;&lt;BR /&gt;
by houseid descending hhincome descending hhtype;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Marius</description>
      <pubDate>Fri, 18 Feb 2011 16:43:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12529#M1372</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-18T16:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace missing values within household level data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12530#M1373</link>
      <description>Thank you for the suggestions everyone. I appreciate the help!!</description>
      <pubDate>Fri, 18 Feb 2011 19:04:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12530#M1373</guid>
      <dc:creator>Tamara_UCD</dc:creator>
      <dc:date>2011-02-18T19:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace missing values within household level data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12531#M1374</link>
      <description>Seems like you can just merge on the income variables after renaming.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data survey;&lt;BR /&gt;
   infile cards missover;&lt;BR /&gt;
   input houseid:$4. subjectid:$5. hhincome hhtype;&lt;BR /&gt;
   cards;&lt;BR /&gt;
1001 10011 10000 2&lt;BR /&gt;
1001 10012 &lt;BR /&gt;
1002 10021 &lt;BR /&gt;
1002 10022 25000 3&lt;BR /&gt;
;;;;&lt;BR /&gt;
&lt;BR /&gt;
data surver2;&lt;BR /&gt;
   merge &lt;BR /&gt;
      survey &lt;BR /&gt;
      survey&lt;BR /&gt;
         (&lt;BR /&gt;
            keep=houseid hh: &lt;BR /&gt;
            rename=(hhincome=income hhtype=type)&lt;BR /&gt;
            where=(not missing(income))&lt;BR /&gt;
         )&lt;BR /&gt;
      ;&lt;BR /&gt;
   by houseid;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
Obs    houseid    subjectid    hhincome    hhtype    income    type&lt;BR /&gt;
&lt;BR /&gt;
 1      1001        10011        10000        2       10000      2&lt;BR /&gt;
 2      1001        10012            .        .       10000      2&lt;BR /&gt;
 3      1002        10021            .        .       25000      3&lt;BR /&gt;
 4      1002        10022        25000        3       25000      3&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 18 Feb 2011 23:21:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12531#M1374</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-02-18T23:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace missing values within household level data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12532#M1375</link>
      <description>Or with a SQL statement:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
	select *, sum(hhincome) as income, sum(hhtype) as type&lt;BR /&gt;
		from temp&lt;BR /&gt;
		group by houseid&lt;BR /&gt;
		;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Warm regards&lt;BR /&gt;
Vasile</description>
      <pubDate>Sat, 19 Feb 2011 02:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-missing-values-within-household-level-data/m-p/12532#M1375</guid>
      <dc:creator>Vasile01</dc:creator>
      <dc:date>2011-02-19T02:53:27Z</dc:date>
    </item>
  </channel>
</rss>

