<?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: Merging two databases with different character variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128573#M294595</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Thank you for the brilliant idea!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I'm still relatively new, I'm not quite sure on how to execute the compress function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;COMPRESS (character-value &amp;lt;,'compress-list'&amp;gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My coding:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**compress**;&lt;/P&gt;&lt;P&gt;data test3;&lt;/P&gt;&lt;P&gt;set test2;&lt;/P&gt;&lt;P&gt;Postcode = COMPRESS (" X ")&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, the problem is that there are a multitude of differing postcodes. One dataset contains 'UB8 1TF' whereas another may possibly have 'UB10 8TF', and hence I am not too sure as to what to replace 'X' with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just to clarify, I want the postcodes to become 'UB81TF' and 'UB108TF' instead of the above - also, there are A LOT of postcodes for this to be done to.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 08 Jul 2013 13:52:11 GMT</pubDate>
    <dc:creator>help93</dc:creator>
    <dc:date>2013-07-08T13:52:11Z</dc:date>
    <item>
      <title>Merging two databases with different character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128571#M294593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey all. I hope all is well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been working on SAS for the last 2 weeks and have come across a problem I can't seem to figure out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Problem:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One database contains the variable 'POSTCODE' in the form of 'UB2&amp;nbsp; 9TF' (UK POSTCODES) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other database contains the variable 'POSTCODE' in the form of 'UB29TF'. How do I go about getting the same variable attributes in order to successfully merge them?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jul 2013 11:59:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128571#M294593</guid>
      <dc:creator>help93</dc:creator>
      <dc:date>2013-07-08T11:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two databases with different character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128572#M294594</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;Have you tried using the compress function to remove spaces (among other characters) in a string?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#n0fcshr0ir3h73n1b845c4aq58hz.htm" title="http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#n0fcshr0ir3h73n1b845c4aq58hz.htm"&gt;SAS(R) 9.3 Functions and CALL Routines: Reference&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jul 2013 12:44:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128572#M294594</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2013-07-08T12:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two databases with different character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128573#M294595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Thank you for the brilliant idea!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I'm still relatively new, I'm not quite sure on how to execute the compress function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;COMPRESS (character-value &amp;lt;,'compress-list'&amp;gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My coding:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**compress**;&lt;/P&gt;&lt;P&gt;data test3;&lt;/P&gt;&lt;P&gt;set test2;&lt;/P&gt;&lt;P&gt;Postcode = COMPRESS (" X ")&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, the problem is that there are a multitude of differing postcodes. One dataset contains 'UB8 1TF' whereas another may possibly have 'UB10 8TF', and hence I am not too sure as to what to replace 'X' with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just to clarify, I want the postcodes to become 'UB81TF' and 'UB108TF' instead of the above - also, there are A LOT of postcodes for this to be done to.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jul 2013 13:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128573#M294595</guid>
      <dc:creator>help93</dc:creator>
      <dc:date>2013-07-08T13:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two databases with different character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128574#M294596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It sounds like you would like to remove the spaces that are embedded into the middle of some of the values of POSTCODE in one or more of the original datasets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data fix1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set data1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; postcode = compress(postcode, ' ');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data fix2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set data2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; postcode = compress(postcode, ' ');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sort data=fix1; by postcode ; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sort data=fix2; by postcode; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; merge fix1 fix2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; by postcode;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or with PROC SQL you might do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sql ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;create table want as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; select *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; from data1 full join data2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; on compress(data1.postcode,' ') = compress(date2.postcode,' ')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jul 2013 14:51:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128574#M294596</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-07-08T14:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two databases with different character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128575#M294597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much Amir and Tom. It's finally compressed! My other question is how do I ensure that the two variables have the same length, informat, format, label, etc,.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, before merging, one database has the format and informat of&amp;nbsp; '$24' whereas the other has '$255'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jul 2013 15:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128575#M294597</guid>
      <dc:creator>help93</dc:creator>
      <dc:date>2013-07-08T15:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two databases with different character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128576#M294598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For character variables the formats and informats you mention are redundant.&amp;nbsp; They probably indicate the length of the respective variables in their tables, both of them overkill if they ar for the postcodes.&amp;nbsp; &lt;/P&gt;&lt;P&gt;You can compare values with different lengths from each of these tables without making any further adjustments, SAS will just pad out the rest of the length (if any) with blanks.&amp;nbsp; Just do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2013 10:23:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128576#M294598</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2013-07-09T10:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two databases with different character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128577#M294599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your postal codes are like mine, you will not only want to use the Compress function as indicated to remove blanks, but also to remove unwanted characters like dashes (i.e. A1A-1A1).&amp;nbsp; Here is a paper with good examples: &lt;A href="http://www2.sas.com/proceedings/forum2007/217-2007.pdf" title="http://www2.sas.com/proceedings/forum2007/217-2007.pdf"&gt;http://www2.sas.com/proceedings/forum2007/217-2007.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a similar way as the compress function, you may want to use the UPCASE function to make any lowercase letters in your postalcode to uppercase (that is, if any lowercases exist).&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2013 15:43:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128577#M294599</guid>
      <dc:creator>jaredp</dc:creator>
      <dc:date>2013-07-09T15:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two databases with different character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128578#M294600</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;if there is only blank characters (more than one in string) then you can also use COMPBL function to remove excess blanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Uma Shanker&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2013 18:06:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-databases-with-different-character-variables/m-p/128578#M294600</guid>
      <dc:creator>umashankersaini</dc:creator>
      <dc:date>2013-07-09T18:06:10Z</dc:date>
    </item>
  </channel>
</rss>

