BookmarkSubscribeRSS Feed
Sean_OConnor
Fluorite | Level 6

Folks,

 

I wonder could anyone provide some ideas for code to help spot anomalies between two variables. I've generated a number of random observations where in some cases there a large differences between values. See the example dataset.

 

As can be seen from the below, these differences could be attributed to human error. An individual keying in an extra 1 or 0 or leaving out a number. Can anyone think of some code which could compare the two numbers and spot issues which could be attributed to keying errors.

 

Would be interested in any ideas.

 

data example;
infile datalines dsd;
   input var1-var2;
   datalines;
12352004,	2352004
12350622,	2350622
10791626,	791626
13112730,	3112730
18028284,	8028284
1999992,		199992
2194664,		21946
3095470,		30954
1076751,		10767
1478045,		14780
962000,		9620
423213,		43213
424649,		4246
500002,		50002
66589,		6589037
17178,		1717800
15000,		150000
12480,		112480
82818,		182818
16304,		116304
19914,		119914
11060,		110060
13568,		110040
323,			323
26738,		26738
32480,		32480
37253,		37253
2500,		2500
3020,		3020
6197,		6197
6986,		6986
1320,		1320
28277,	28277
;run;
2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You could use compged function to see how similar they are (convert to text, then compare):

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002206133.htm

 

However it is going to be difficult with a set of guiding rules as

123456789 compared to 234567891 is more or less the same, but a very different number

Astounding
PROC Star

I agree with reading them as character.  One possible approach:  ignore position.  Break up each string into a set of 10 counts:  how many 0's, how many 1's, etc.  Then examine the differences in those counts.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 794 views
  • 4 likes
  • 3 in conversation