BookmarkSubscribeRSS Feed
sssb2000
Calcite | Level 5
hi,
i have a table "search" with one or more obs (variables A-M)
i also have a huge table "Sasuser.Data1" which has 1 million obs (variables A-M and Variables O and P)

what i need to do is search my DATA1 table for the obs in "search" and IF there is a match for ALL variables (A-M), then return variables O and P.


is this possible?

what is have so far is:

Libname sasuser;
options nodate pageno=1 linesize=80 pagesize=40;
proce compare base=work.search compare = sasuser.data1 listequalvar;
??????
run;
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi!
Rather than use PROC COMPARE, I'd probably do an SQL join or a SAS merge with a BY statement. The only downside of the SAS merge is that both datasets need to be sorted by the variables in the BY statement. And, it's only a downside if you don't have enough memory to sort the big dataset.
Here's an SQL join example to create your table:
[pre]
proc sql;
create table getsearch as
select srch.a, srch.b, srch.c, srch.d, srch.e, srch.f,
srch.g, srch.h, srch.i, srch.j, srch.k, srch.l
srch.m, big.o, big.p
from search as srch,
sasuser.data1 as big
where srch.a=big.a and
srch.b=big.b and
srch.c=big.c and
srch.d=big.d and
srch.e=big.e and
srch.f=big.f and
srch.g=big.g and
srch.h=big.h and
srch.i=big.i and
srch.j=big.j and
srch.k=big.k and
srch.l=big.l and
srch.m=big.m;
quit;

proc print data=getsearch;
run;
[/pre]

If you need more help, you might consider contacting SAS Technical Support, because, depending on the size of your files and subsequent processing and whether you need to have the non-matches as well as the matches, it might turn out that a MERGE would work out better for you. They could help you understand how a Data Step MERGE differs from an SQL join. To find out how to contact Tech Support, refer to:
http://support.sas.com/techsup/contact/index.html

Good luck,
cynthia

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
  • 1 reply
  • 578 views
  • 0 likes
  • 2 in conversation