BookmarkSubscribeRSS Feed
alienographer
Calcite | Level 5
Hi,
NE Washington DC newbie user here. Tried using manuals and online help and just a little lost. I am trying to use the proc compare command to compare the data in two tables. However, the two tables of data appear to be sorted differently.

Thus the delimma how to write a query that will order the data in away that I can compare to tables.

The query.

libname xdata 'c:\SAS_Testing\ndprod3';

proc compare data=xdata.county_msa compare=xdata.county_msa1 ;
run;
proc sql;
select * from xdata.county_msa
where state_fips = '72'
order by cnty;
quit;

The results.

The COMPARE Procedure
Comparison of XDATA.COUNTY_MSA with XDATA.COUNTY_MSA1
(Method=EXACT)

Data Set Summary

Dataset Created Modified NVar NObs

XDATA.COUNTY_MSA 04FEB08:14:53:42 04FEB08:14:53:58 12 970599
XDATA.COUNTY_MSA1 07FEB08:11:31:27 07FEB08:11:31:27 12 970599


Variables Summary

Number of Variables in Common: 12.
Number of Variables with Differing Attributes: 12.


Value Comparison Results for Variables

__________________________________________________________
|| state_fips
|| Base Value Compare Value
Obs || state_fips state_fips
________ || __ __
||
1 || 01 48
2 || 01 48
3 || 01 48
4 || 01 48
5 || 01 48
6 || 01 48
7 || 01 48
8 || 01 48
9 || 01 48


__________________________________________________________
|| cnty
|| Base Value Compare Value
Obs || cnty cnty
________ || ___ ___
||
1 || 001 059
2 || 001 059
3 || 001 059
4 || 001 059
5 || 001 059
6 || 001 059


Any help would be greatly appreciated.
Thanks
Alienographer
2 REPLIES 2
deleted_user
Not applicable
SAS is a JIT compiled language. It reads of code block, compiles it, and then executes it.

[pre]
Proc Compare ...;
run;
[/pre]

Is a textual block that is compiled to machine code and then executed.

next

[pre]
Proc Sql;
Select ....;
[/pre]

is compiled and executed.

If you wanted to use compare the sorted files, you need to

[pre]
proc sort data=indata1 out=outdata1; by key_value;
proc sort data=indata2 out=outdata2; by key_value;

proc compare data=outdata1 compare=outdata2;
run;
quit;
[/pre]

Or to use proc sql

[pre]
proc sql;
create table outdata1 as
select * from ... where ... order by ... ;

create table outdata2 as
select * from ... where ... order by ... ;
quit;

proc compare ... ;
run;
quit;
[/pre]
Doc_Duke
Rhodochrosite | Level 12
I'm not sure why you are trying to do this directly in code. If you are using EGuide (the topic of this group), the compare task is under the data tab. It leads you through it and sorts and sets up the keys for you.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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