Help using Base SAS procedures

How to compare data sets

Reply
New Contributor
Posts: 2

How to compare data sets

Hi,

    Am having trouble getting each row in one data set to compare/join with all the rows in a second data set,

as in the attached file. Have tried many many variations but still cannot get the desired result.

Running SAS 9.1.3 Service Pack 4 in Redhat Linux.

Thanks in advance.

Regards,

             Allan.

Attachment
PROC Star
Posts: 7,474

How to compare data sets

Posted in reply to Ballswool

Since all you appear to want is the cartesian product of the two files, I would think that using proc sql would be the easiest way to get it.  E.g.,

proc sql;

  create table want as

    select *

      from file1,file2

  ;

quit;

New Contributor
Posts: 2

How to compare data sets

art,

      Thanks for the reply, I can see how it would be possible with sql, though a bit complex.

Would still prefer to be able to compare each row of file1 with every row on file2.

The data would be from a survey on a 50 x 50 meter grid where file1 would contain two numerical

values x1 y1 where one unit represents 50m with the origin at say  0 0.

file2 would contain a grid  x2 y2 with an origin of 25 by 25.

Rows in file1 represent points that cannot be accessed and need to be moved by a maximum radius

to a point on the second grid such that points from file1 will be allocated to points in file2 only once

and points in file2 will only be matched with a point from file1 once.

Both files could be in the thousands.

Regards,

             Allan.

Super User
Super User
Posts: 7,050

How to compare data sets

Posted in reply to Ballswool

You can make a dataset solution that does a cartesian product.

data want ;

   set one;

   do _p=1 to _nobs;

     set two point=_p nobs=_nobs;

     output;

   end;

run;

Ask a Question
Discussion stats
  • 3 replies
  • 130 views
  • 3 likes
  • 3 in conversation