<?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: Hierarchical Merge in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Hierarchical-Merge/m-p/155055#M30383</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since both of your County_Hh and County_Pop data sets contain&amp;nbsp; the "county", which I recognize as FIPS or whatever they changed the name to codes, and a State code I would instead use the SAS supplied FIPSTATE or FIPNAMEL function to create the desired text instead of bothering to merge a third dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add code:&lt;/P&gt;&lt;P&gt;sName = FIPNAMEL(state);&lt;/P&gt;&lt;P&gt;to the data set merging the two sets.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 May 2014 14:53:57 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2014-05-12T14:53:57Z</dc:date>
    <item>
      <title>Hierarchical Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hierarchical-Merge/m-p/155054#M30382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi SAS friends,&lt;/P&gt;&lt;P&gt;I was wondering if it is possible to merge on a higher level variable simultaneously. for example to merge on state and county in one step (all state codes are built into county codes).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data County_Pop;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input State :$2. County :$5. cName :$25. Population;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format Population Comma16.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;01 01001 Autauga 222135&lt;/P&gt;&lt;P&gt;01 01011 Bullock 300000&lt;/P&gt;&lt;P&gt;01 01023 Choctaw 115000&lt;/P&gt;&lt;P&gt;42 42003 Allegheny 389471&lt;/P&gt;&lt;P&gt;42 42101 Philadelphia 2689765&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;&lt;/P&gt;&lt;P&gt;data County_HH;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input State :$2. County :$5. cName :$25. Households;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format Households Comma16.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;01 01001 Autauga 106625&lt;/P&gt;&lt;P&gt;01 01011 Bullock 144000&lt;/P&gt;&lt;P&gt;01 01023 Choctaw 55200&lt;/P&gt;&lt;P&gt;42 42003 Allegheny 186946&lt;/P&gt;&lt;P&gt;42 42101 Philadelphia 1291087&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data State_Names;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input State :$2. sName $25.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;01 Alabama&lt;/P&gt;&lt;P&gt;42 Pennsylvania&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge County_HH County_Pop State_Names;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by ??? ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 14:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hierarchical-Merge/m-p/155054#M30382</guid>
      <dc:creator>SAShole</dc:creator>
      <dc:date>2014-05-12T14:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: Hierarchical Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hierarchical-Merge/m-p/155055#M30383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since both of your County_Hh and County_Pop data sets contain&amp;nbsp; the "county", which I recognize as FIPS or whatever they changed the name to codes, and a State code I would instead use the SAS supplied FIPSTATE or FIPNAMEL function to create the desired text instead of bothering to merge a third dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add code:&lt;/P&gt;&lt;P&gt;sName = FIPNAMEL(state);&lt;/P&gt;&lt;P&gt;to the data set merging the two sets.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 14:53:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hierarchical-Merge/m-p/155055#M30383</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-05-12T14:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: Hierarchical Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hierarchical-Merge/m-p/155056#M30384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks ballardw. i never knew about the FIPNAMEL function. Do you know if there is a similar function for Census Region/Division?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 17:18:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hierarchical-Merge/m-p/155056#M30384</guid>
      <dc:creator>SAShole</dc:creator>
      <dc:date>2014-05-12T17:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Hierarchical Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hierarchical-Merge/m-p/155057#M30385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No function I am aware of. However if you can get any list of code values with text you want to display it is not very difficult to create a custom format that will display the desired value OR use a Put statement to create a new variable. Look up Proc Format and a CNTLIN dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hash tables and/or sql joins are also another way to merge data if you can get the codes and values in a dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 19:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hierarchical-Merge/m-p/155057#M30385</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-05-12T19:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Hierarchical Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hierarchical-Merge/m-p/155058#M30386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not aware of this functions mentioned above by ballardw..i did normal merge on your data to map the state names and codes...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=County_Pop;by State County cName; run;&lt;/P&gt;&lt;P&gt;proc sort data=County_HH;by State County cName; run;&lt;/P&gt;&lt;P&gt;proc sort data=State_Names;by State; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt; merge County_Pop(in=a) County_HH(in=b) State_Names (in=c);&lt;/P&gt;&lt;P&gt; by State ;&lt;/P&gt;&lt;P&gt; if a and b;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By running the above code i got the o/p as follows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="419"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="39"&gt;State&lt;/TD&gt;&lt;TD class="xl65" width="51"&gt;County&lt;/TD&gt;&lt;TD class="xl65" width="85"&gt;cName&lt;/TD&gt;&lt;TD class="xl65" width="75"&gt;Population&lt;/TD&gt;&lt;TD class="xl65" width="80"&gt;Households&lt;/TD&gt;&lt;TD class="xl65" width="89"&gt;sName&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20"&gt;01&lt;/TD&gt;&lt;TD class="xl63"&gt;01001&lt;/TD&gt;&lt;TD class="xl63"&gt;Autauga&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;222,135&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;106,625&lt;/TD&gt;&lt;TD class="xl63"&gt;Alabama&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20"&gt;01&lt;/TD&gt;&lt;TD class="xl63"&gt;01011&lt;/TD&gt;&lt;TD class="xl63"&gt;Bullock&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;300,000&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;144,000&lt;/TD&gt;&lt;TD class="xl63"&gt;Alabama&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20"&gt;01&lt;/TD&gt;&lt;TD class="xl63"&gt;01023&lt;/TD&gt;&lt;TD class="xl63"&gt;Choctaw&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;115,000&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;55,200&lt;/TD&gt;&lt;TD class="xl63"&gt;Alabama&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20"&gt;42&lt;/TD&gt;&lt;TD class="xl63"&gt;42003&lt;/TD&gt;&lt;TD class="xl63"&gt;Allegheny&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;389,471&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;186,946&lt;/TD&gt;&lt;TD class="xl63"&gt;Pennsylvania&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20"&gt;42&lt;/TD&gt;&lt;TD class="xl63"&gt;42101&lt;/TD&gt;&lt;TD class="xl63"&gt;Philadelphia&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;2,689,765&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;1,291,087&lt;/TD&gt;&lt;TD class="xl63"&gt;Pennsylvania&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2014 11:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hierarchical-Merge/m-p/155058#M30386</guid>
      <dc:creator>Vish33</dc:creator>
      <dc:date>2014-05-13T11:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Hierarchical Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hierarchical-Merge/m-p/155059#M30387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I developed the attached SAS macro (util_addCensusRegnDiv.sas) sometime ago, and here is a usage example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* ***************************************************** */&lt;/P&gt;&lt;P&gt;/* Add Census Regions and Divisions of the United States */&lt;/P&gt;&lt;P&gt;/* ***************************************************** */&lt;/P&gt;&lt;P&gt;%util_addCensusRegnDiv( p_dsName=county_HH, p_stateVarName=%str(input(state,$2.)) );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Ahmed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2014 12:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hierarchical-Merge/m-p/155059#M30387</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2014-05-13T12:09:27Z</dc:date>
    </item>
  </channel>
</rss>

