<?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: list of Census house records, where 2 or more occupants are related to the primary head of household in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/list-of-Census-house-records-where-2-or-more-occupants-are/m-p/218538#M53754</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you can assume that &lt;SPAN style="text-decoration: underline;"&gt;MIN(id) is Self for every house&lt;/SPAN&gt; then you don't need a join :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table SelfWithTwoRelatives as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select min(id) as id, house&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from myData &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;group by house&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;having sum(RelationshipToRespondent = "Relative") &amp;gt;= 2;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 23 May 2015 02:30:15 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2015-05-23T02:30:15Z</dc:date>
    <item>
      <title>list of Census house records, where 2 or more occupants are related to the primary head of household</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/list-of-Census-house-records-where-2-or-more-occupants-are/m-p/218535#M53751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a Census data file of persons who occupy various houses. Sample data shown below.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image" src="https://communities.sas.com/legacyfs/online/10561_Capture.PNG" /&gt;&lt;/P&gt;&lt;P&gt;In every house, there is always a person numbered "1" who is the primary respondent to the Census survey (known as the head of household). Sometimes, this person lives alone. Or with relatives, or nonrelatives, or a combination of both. I want to create a list of the HouseNumbers that correspond to houses in which the head of household (person 1) is living with &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;at least 2&lt;/STRONG&gt;&lt;/SPAN&gt; of his or her relatives. So using the above example, the output would be:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture2.PNG" class="jive-image-thumbnail jive-image" height="131" src="https://communities.sas.com/legacyfs/online/10562_Capture2.PNG" style="height: 131px; width: 655px;" width="655" /&gt;&lt;/P&gt;&lt;P&gt;House #128 would not be included, because person 1 ("self", also known as the respondent) is only related to one other person in house #128. Also, house #136 and house #149 would not be included because the respondent lives alone (no relatives or nonrelatives). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my output table, I only want two variables: ID and House.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 May 2015 00:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/list-of-Census-house-records-where-2-or-more-occupants-are/m-p/218535#M53751</guid>
      <dc:creator>Bautista</dc:creator>
      <dc:date>2015-05-23T00:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: list of Census house records, where 2 or more occupants are related to the primary head of household</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/list-of-Census-house-records-where-2-or-more-occupants-are/m-p/218536#M53752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you can't assume that the primary respondent in a house has the smallest ID then you need:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table SelfWithTwoRelatives as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select b.id, b.house&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from (&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; select house &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; from myData &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; group by house&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; having sum(RelationshipToRespondent = "Relative") &amp;gt;= 2) as a inner join&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; myData as b on a.house=b.house&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;where b.RelationshipToRespondent="Self";&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(Couldn't test against your data which can't be imported into SAS)&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 May 2015 01:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/list-of-Census-house-records-where-2-or-more-occupants-are/m-p/218536#M53752</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-05-23T01:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: list of Census house records, where 2 or more occupants are related to the primary head of household</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/list-of-Census-house-records-where-2-or-more-occupants-are/m-p/218537#M53753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select min(id) as id,a.house from have a&lt;/P&gt;&lt;P&gt;left join (select house,count(*) as freq from have&lt;/P&gt;&lt;P&gt;where relationshiptorespondent='Relative' group by house) b&lt;/P&gt;&lt;P&gt;on a.house=b.house&lt;/P&gt;&lt;P&gt;group by a.house&lt;/P&gt;&lt;P&gt;having freq&amp;gt;=2;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=want;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 May 2015 02:09:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/list-of-Census-house-records-where-2-or-more-occupants-are/m-p/218537#M53753</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-05-23T02:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: list of Census house records, where 2 or more occupants are related to the primary head of household</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/list-of-Census-house-records-where-2-or-more-occupants-are/m-p/218538#M53754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you can assume that &lt;SPAN style="text-decoration: underline;"&gt;MIN(id) is Self for every house&lt;/SPAN&gt; then you don't need a join :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table SelfWithTwoRelatives as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select min(id) as id, house&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from myData &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;group by house&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;having sum(RelationshipToRespondent = "Relative") &amp;gt;= 2;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 May 2015 02:30:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/list-of-Census-house-records-where-2-or-more-occupants-are/m-p/218538#M53754</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-05-23T02:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: list of Census house records, where 2 or more occupants are related to the primary head of household</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/list-of-Census-house-records-where-2-or-more-occupants-are/m-p/218539#M53755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PG,&lt;/P&gt;&lt;P&gt;HAVING also can filter the obs ,not just the group .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table SelfWithTwoRelatives as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from myData&lt;/P&gt;&lt;P&gt;group by house&lt;/P&gt;&lt;P&gt;having sum(RelationshipToRespondent = "Relative") &amp;gt;= 2 and &lt;STRONG&gt;PersonNumber=1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 May 2015 06:11:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/list-of-Census-house-records-where-2-or-more-occupants-are/m-p/218539#M53755</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-05-23T06:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: list of Census house records, where 2 or more occupants are related to the primary head of household</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/list-of-Census-house-records-where-2-or-more-occupants-are/m-p/218540#M53756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="645292" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A __default_attr="813022" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Great! This query can even be done without a join and without remerging (implicit join) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table SelfWithTwoRelatives as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; max(case when RelationshipToRespondent="Self" then id else . end) as id,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; house&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from myData&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;group by house&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;having sum(RelationshipToRespondent = "Relative") &amp;gt;= 2;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 May 2015 20:14:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/list-of-Census-house-records-where-2-or-more-occupants-are/m-p/218540#M53756</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-05-23T20:14:48Z</dc:date>
    </item>
  </channel>
</rss>

