Is there any method to merge two datasets without using MERGE statement . it might be simple question . but as I am new to SAS , Please provide the information . thanks!!
Friend,
Use proc sql using inner join instead of merge statement...
Ankit
Depends on what you are trying to do. Does the following approximate what you are calling merging?
data one;
input x;
cards;
1
2
3
;
data two;
input y $;
cards;
a
b
c
;
data both;
set one;
set two;
run;
HTH,
Art
Hi, You can use the proc sql statement to join your two tables.
the inner join is the match join. You'll need your id in the two tables to have it as output.
the left or right join permitts to join a source table with an other and one of the tables is used as reference.
the full join just tries to match your two tables. it's the less used.
when you want to merge data, and since MERGE is obvious, why would you resist using it ? ^
Hi,
There are lot of methods available for merging 2 datasets. But which method you use is based on the type of data and number of observation it has.
1. PROC SQL;
SELECT VAR1,VAR2,T1.VAR3,VAR4,VAR5
FROM TABLE1 AS T1,TABLE2 AS T2
WHERE T1.VAR3=T2.VAR1;
QUIT;
In PROC SQL itself there are many methods available (Inner Join, Left Join, Right Join) and apart from that you can use SET operators (EXCEPT,INTERCEPT, UNION) to merge datasets. (But each one serve different purpose).
2. SET statement
a) DATA dataset-name;
SET sas-dataset;
SET sas-dataset;
RUN;
b) DATA dataset-name;
SET sas-dataset;
SET sas-dataset KEY=index-name;
RUN;
When you specify the index name in the KEY=option, processing changes from sequential to direct access, and SAS reads only the observation that satisfies the lookup.
Hope this answers your question.
Thanks
Dhanasekaran R
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.