DATA Step, Macro, Functions and more

Limiting the observations

Reply
Contributor
Posts: 69

Limiting the observations

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
Contributor
Posts: 31

Re: Limiting the observations

Posted in reply to Siddhartha
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 Smiley Happy

Thanks!
Super Contributor
Super Contributor
Posts: 3,174

Re: Limiting the observations

Posted in reply to Siddhartha
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.
Ask a Question
Discussion stats
  • 2 replies
  • 129 views
  • 0 likes
  • 3 in conversation