equivalent of inner join in SAS

Today, I will discuss about “How to design code in SAS which is equivalent to inner join in database where column name are different in both the data sets or tables in terms of database.
Below is the data in two tables.


Now, apply inner Join in both the tables on condition COL1=COL4 and below is the output of the same.


Next step , try to first create the same dataset in SAS and then apply logic on that data to get result equivalent of inner join.
Create the dataset same as TEST1 and TEST2 tables data in SAS.

* If you see in second dateset which is TEST2, we applied the sort logic as COL4= “4” kept intentionally at third row to showcase sorting technique in SAS.
* If you will not sort the data in SAS , your output will get changed.

Now, apply the Joining condition to get the results same as database result.

See the final output in SAS.

Add all the SAS code(dateset creation and joining logic) and run it, you will get above result.

Related posts