|
I don't recall ever having a problem comparing a character variable of any
length with a constant consisting of a single blank. When
character expressions to be compared have different lengths, SAS pads the
shorter one with blanks to make the lengths equal. So
CHARVAR = ' '
evaluates to TRUE if CHARVAR is all blanks, regardless of the length of
CHARVAR.
On Tue, 21 Nov 2000 13:40:34 GMT, John M. Wildenthal
<jmwildenthal@MY-DEJA.COM> wrote:
>In article <OFFC40886F.76E0E68E-ON8525699D.0083A213@ckfr.com>,
> PAdkins@CHECKFREE.COM wrote:
>> Beginner SAS MVS question:
>>
>> Can someone help me out? It's seems simple, but my output is showing
>data
>> as follows:
>>
>> TAX_ID LNAME_PREV FNAME_PREV LNAME_CURRENT
>> FNAME_CURRENT
>> 123456789
>> JONES MARY
>> 235158764 SMITH
>> TOM
>>
>> I don't want output if you're not in the previous table with variables
>> LNAME_PREV & FNAME_PREV.
>> I'm trying to output changes in names. If I'm saying delete if the
>> character variable is blank, then why is it in my output?
>>
>> DATA FINAL;
>> MERGE SUBSEP(IN = SEP) SUBOCT(IN = OCT);
>> BY TAX_ID;
>> IF SEP =0 AND OCT = 1 THEN OUTPUT;
>> IF LNAME_PREV=' ' OR FNAME_PREV=' ' THEN DELETE;
>> RUN;
>>
>> If it were working properly, it should look like this because Mary
>Adkins
>> got married and is now Mary Jones.
>>
>> TAX_ID LNAME_PREV FNAME_PREV LNAME_CURRENT
>> FNAME_CURRENT
>> 123456789 ADKINS MARY JONES
>MARY
>>
>
>Gerhard pointed out the relative position of the OUTPUT statement.
>Another possible problem is if either of the *_PREV fields is multiple
>blanks (e.g. ' ' which has length=4), it won't be equal. You can
>use the COMPRESS function to eliminate all but one space:
>
>IF COMPRESS(LNAME_PREV) EQ ' ' THEN DELETE;
>
>If you are trying to store the latest snapshot and a data set of all
>changes (timestamped by the datetime the change was discovered), I have
>a program that does that for Oracle tables, but the log is for all
>changes. It can be modified to track any datasource that can be
>referenced with a LIBNAME engine.
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
|