Help using Base SAS procedures

PROC COMPARE: Processing output dataset

Reply
Contributor
Posts: 32

PROC COMPARE: Processing output dataset

In the following example:
DATA A;
KEY = 100;
Value1 = 200; Value2 = 400;
run;

Data B;
KEY = 100;
Value1 = 200; Value2 = 410;
run;

proc compare BASE=A COMPARE=B CRITERION=2 NOSUMMARY METHOD=ABSOLUTE NOPRINT OUTNOEQUAL OUT=MYDIFFS;
ID KEY;
run;

The dataset MYDIFFS contains 1 record, as follows (and as expected):
_TYPE_ = DIF
_OBS_ = 1
KEY = 100
Value1 = E
Value2 = 10

However if I try and process the MYDIFFS dataset and attempt to change the E to a 0, SAS will throw an error since Value1/2 are numeric. Is there a simple solution to this?
Respected Advisor
Posts: 3,777

Re: PROC COMPARE: Processing output dataset

The value is actually special missing value E. To refere to this in code use .E

if value1 eq .E then ...
Contributor
Posts: 32

Re: PROC COMPARE: Processing output dataset

15 years of coding SAS and I had never heard of that one. Thanks.
Respected Advisor
Posts: 3,777

Re: PROC COMPARE: Processing output dataset

You might like the "generic" missing function. You don't need to know the type.

if missing(value1) then...

Also coalesce if nice for a missing to non-missing value conversion.

[pre]
44 data _null_;
45 do y = 1,.e,3;
46 z = coalesce(y,0);
47 put (_all_)(=);
48 end;
49 run;

y=1 z=1
y=E z=0
y=3 z=3
[pre]
Trusted Advisor
Posts: 2,113

Re: PROC COMPARE: Processing output dataset

"Special missing values" have been around since at least version 5.

They are extensively used in certain pockets of analysis (like surveys where you want to code the reason that a value is missing), but many people go through their entire SAS careers without needing them.

I've rarely needed them, but when I did they were a very valuable tool.

Doc
Ask a Question
Discussion stats
  • 4 replies
  • 139 views
  • 0 likes
  • 3 in conversation