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.

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!

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.

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
  • 2 replies
  • 717 views
  • 0 likes
  • 3 in conversation