Desktop productivity for business analysts and programmers

Sas beginner question for the group

Reply
N/A
Posts: 1

Sas beginner question for the group

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
N/A
Posts: 0

Re: Sas beginner question for the group

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]
Valued Guide
Posts: 2,111

Re: Sas beginner question for the group

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.
Ask a Question
Discussion stats
  • 2 replies
  • 90 views
  • 0 likes
  • 3 in conversation