BookmarkSubscribeRSS Feed
kaushiklu
Calcite | Level 5

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!!

5 REPLIES 5
Ankitsas
Calcite | Level 5

Friend,

Use proc sql using inner join instead of merge statement...

Ankit

art297
Opal | Level 21

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

mojerry2
Fluorite | Level 6

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.

Peter_C
Rhodochrosite | Level 12

when you want to merge data, and since MERGE is obvious, why would you resist using it ? ^

dhana
Fluorite | Level 6

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

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
  • 5 replies
  • 1205 views
  • 0 likes
  • 6 in conversation