<?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: Merge two records into one in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-records-into-one/m-p/106673#M22227</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems a good way. I'll give you feedback later, maybe in one week.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Apr 2013 18:34:48 GMT</pubDate>
    <dc:creator>Demographer</dc:creator>
    <dc:date>2013-04-12T18:34:48Z</dc:date>
    <item>
      <title>Merge two records into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-records-into-one/m-p/106671#M22225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a dataset in which each line is a person with variables such as age, sex, language, etc. There is also a variable that links people living in a same household (HHNUM). With those data, I want to create a new dataset that keep all women aged between 15 and 49 years old, with a new variable that indicates if there is a child aged between 0 and 1 in her household. I guess it's a routine step, but I don't know what to do for this purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS. This board is really awesome. Thank for all. I hope I will be able to help other users when I'll be more familiar with SAS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Apr 2013 17:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-records-into-one/m-p/106671#M22225</guid>
      <dc:creator>Demographer</dc:creator>
      <dc:date>2013-04-12T17:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two records into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-records-into-one/m-p/106672#M22226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;Here is a very not most efficient code:&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input age sex $ hhnum;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;0 F 1&lt;/P&gt;&lt;P&gt;10 M 1&lt;/P&gt;&lt;P&gt;45 F 1&lt;/P&gt;&lt;P&gt;43 M 1&lt;/P&gt;&lt;P&gt;10 F 2&lt;/P&gt;&lt;P&gt;10 M 2&lt;/P&gt;&lt;P&gt;15 F 2&lt;/P&gt;&lt;P&gt;43 M 2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;*create an indicator for child in household or not;&lt;/P&gt;&lt;P&gt;data temp(keep = hhnum child_flag);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;child_flag = ( age = 0 or age = 1);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data = temp;by hhnum child_flag;run;&lt;/P&gt;&lt;P&gt;data temp2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by hhnum;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last.hhnum;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; merge have(where = (sex = "F" &amp;amp; 15 &amp;lt;= age &amp;lt;= 49))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by hhnum;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let me know if it works?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Apr 2013 17:43:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-records-into-one/m-p/106672#M22226</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-04-12T17:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two records into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-records-into-one/m-p/106673#M22227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems a good way. I'll give you feedback later, maybe in one week.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Apr 2013 18:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-records-into-one/m-p/106673#M22227</guid>
      <dc:creator>Demographer</dc:creator>
      <dc:date>2013-04-12T18:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two records into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-records-into-one/m-p/106674#M22228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you don't mind tasting some flavor of Proc SQL, here is another way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select *, case when sum(0&amp;lt;=age&amp;lt;=1)&amp;gt;0 then 1 else 0 end as child_flag &lt;/P&gt;&lt;P&gt;from have&lt;/P&gt;&lt;P&gt;group by hhnum&lt;/P&gt;&lt;P&gt;having sex='F' and 15&amp;lt;=age&amp;lt;=49&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Apr 2013 20:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-records-into-one/m-p/106674#M22228</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-04-12T20:43:58Z</dc:date>
    </item>
  </channel>
</rss>

