Re: Merging two databases with different character variables

As I'm still relatively new, I'm not quite sure on how to execute the compress function.

The function:

COMPRESS (character-value <,'compress-list'>)

My coding:

**compress**;

data test3;

set test2;

Postcode = COMPRESS (" X ")

run;

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.

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.

Re: Merging two databases with different character variables

For character variables the formats and informats you mention are redundant. They probably indicate the length of the respective variables in their tables, both of them overkill if they ar for the postcodes.

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. Just do it.

Re: Merging two databases with different character variables

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). Here is a paper with good examples: http://www2.sas.com/proceedings/forum2007/217-2007.pdf

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).