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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 722 views
  • 0 likes
  • 3 in conversation