BookmarkSubscribeRSS Feed
Siddhartha
Calcite | Level 5
Can we limit the observations while joining two datasets with common id x like x<30.
Could anyone help me which is efficient in joining the datasets, is it merge or proc sql.

Regards,
Sidhu
2 REPLIES 2
SushilNayak
Obsidian | Level 7
Hey Sid,
use the dataset options on the imcoming datasets @ merge step or from clause in sql. Based on data that you have got, you can yourself find out which technique would be better/efficient

data d1;
input id name $10.;
datalines;
10 sushil
20 sas
;;;
run;
data d2;
input id lname $10.;
datalines;
10 nayak
20 base
;;;
run;
data final;
merge d1(in=a firstobs=1 obs=1)
d2(in=b where=(id<20));
by id;
if a and b;
run;
proc print;run;


Things to learn and understand:
WHERE= dataset option usage and working in SQL and datastep

Hope this helps 🙂

Thanks!
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The SAS support http://support.sas.com/ website has not only SAS-hosted product documentation but also supplemental technical and conference topic-related papers. Using the website SEARCH facility or possibly using the Google advanced search argument below revealed several interesting references to consider reviewing:

proc sql merge site:sas.com


Scott Barry
SBBWorks, Inc.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1201 views
  • 0 likes
  • 3 in conversation