SAS Procedures

Help using Base SAS procedures
BookmarkSubscribeRSS Feed
omega1983
Calcite | Level 5


data trial;

merge trial1

         trial2;

by  ???

run;

trial1 has the field gen_id

trial2 has the field sys_id

they are an equal join but with different names.  If they had the same name it would be a simple by statement.  How can I join these two when they have equal value and different names?

3 REPLIES 3
Anotherdream
Quartz | Level 8

data trial;

merge trial1(rename=(gen_id=sys_id)) trial2;

by sys_id;

run;


Haikuo
Onyx | Level 15

Choose the "id" you want to keep and rename the other one:

data trial;

   merge trial1 /*keeping gen_id*/

             trial2 (rename=sys_id=gen_id);

by gen_id;

run;

Or without renaming/Sorting, use

Proc sql;

   create table trail as

    select *  from trail1 a, trial2 b where  a.gen_id=b.sys_id;

quit;

Haikuo

DBailey
Lapis Lazuli | Level 10

proc sql;

create table trial as

select

     *

from

     trial1 t1

     inner join trial2 t2

          on t1.gen_id=t2.sys_id;

quit;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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