BookmarkSubscribeRSS Feed
DavidJ
Calcite | Level 5
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?
4 REPLIES 4
data_null__
Jade | Level 19
The value is actually special missing value E. To refere to this in code use .E

if value1 eq .E then ...
DavidJ
Calcite | Level 5
15 years of coding SAS and I had never heard of that one. Thanks.
data_null__
Jade | Level 19
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]
Doc_Duke
Rhodochrosite | Level 12
"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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 752 views
  • 0 likes
  • 3 in conversation