SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

about efficient way compare tables in SAS

Accepted Solution Solved
Reply
Regular Contributor
Posts: 213
Accepted Solution

about efficient way compare tables in SAS

Hi All,

 

    I am using SAS grid server at Linux. I want to test the tables on different servers (Teradata serve or SQL server) to see whether they are the same.  

   Right now I'm using "proc sort"  then "Proc compare",  it takes long time for big tables. I wonder whether there is any other more efficient way for this data compare purpose? Thank you!

 

Jade


Accepted Solutions
Solution
‎10-26-2017 11:49 AM
Super User
Posts: 3,761

Re: about efficient way compare tables in SAS

The only way SAS can compare tables from different database servers using PROC COMPARE would be to copy the tables into SAS first. This would explain why it is taking so long. It would be helpful if you could post some sample SAS code for one of your compares.

View solution in original post


All Replies
Solution
‎10-26-2017 11:49 AM
Super User
Posts: 3,761

Re: about efficient way compare tables in SAS

The only way SAS can compare tables from different database servers using PROC COMPARE would be to copy the tables into SAS first. This would explain why it is taking so long. It would be helpful if you could post some sample SAS code for one of your compares.

Respected Advisor
Posts: 4,540

Re: about efficient way compare tables in SAS

[ Edited ]

@Jade_SAS

To compare data from different environments your first step will always be to load the data into a common environment. In doing so there will always be some sort of data conversion and the only thing you can really compare is the data after conversion (=do I get the same data in my target environment from both sources).

 

If you plan to use the data later on in SAS then loading into SAS for comparison feels like the right thing to do. If you want to speed up elapsed time then consider to implement 3 jobs: Job 1 and 2 load the data from source into SAS and can run in parallel, job 3 doing the comparison depends on job 1&2 and can execute once both tables exist in SAS.

 

If using Proc Compare then make sure to either use the FUZZ= argument (i.e. fuzz=0.00000001) or to use the round() function on all numerical variables with fractional values when loading the data into SAS tables.

http://documentation.sas.com/?docsetId=lrcon&docsetTarget=p0ji1unv6thm0dn1gp4t01a1u0g6.htm&docsetVer...

 

 

Regular Contributor
Posts: 213

Re: about efficient way compare tables in SAS

Thank you SASKiwi and Patrick!

If I want to add one filter on one SQL table, is there a way in SAS that I can let the query execute in SQL server (the original table server) instead of in SAS? According to your post, this seems not possible, right?

Regular Contributor
Posts: 213

Re: about efficient way compare tables in SAS

Another question is how can we get the rows in table A but not in Table B (or vice versa) when using Proc Compare? thank you!

 

Jade

Respected Advisor
Posts: 4,540

Re: about efficient way compare tables in SAS

@Jade_SAS

If you want to filter the data before the comparison then simply add this filter condition to the SQL which reads the source table.

If you want to execute the comparison in SQL Server then you need the data in SQL server and you need to use code which executes fully in SQL Server (=out of SAS: Explicit Pass-through SQL).

Proc Compare is a SAS Procedure and it needs the data in SAS. You can use a libname statement pointing to your SQL Server tables and then use Proc Compare but this will still pull all the data into SAS before executing the comparison.

Regular Contributor
Posts: 213

Re: about efficient way compare tables in SAS

Thank you so much!

Jade

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 455 views
  • 3 likes
  • 3 in conversation