BookmarkSubscribeRSS Feed
zhangda
Fluorite | Level 6

Hi,

 

A quick question, what is the easiest way to get table C where only two columns there, num=5 and index=a, thanks!

 

data A;
input num index $;
cards;
1 a
2 a
3 a
4 a
;
run;

data B;
input num index $;
cards;
1 a
2 a
3 a
4 a
5 a
;
run;

2 REPLIES 2
ballardw
Super User

What does C look like? What does it come from?

 

Easiest from your description might well be:

data c;
input num index $;
cards;
;
run;

 

so I think you are missing some details of your issue.

Astounding
PROC Star

Sort your data sets if they are not already in order:

 

proc sort data=a; by num index; run;

proc sort data=b; by num index; run;

 

In this case, your data sets are already in order and don't need to be sorted.  

 

Then to find the mismatch:

 

data c;

merge a (in=in_a)  b (in=in_b);

by num index;

if in_a=0;

run;

 

In this case, the program doesn't actually need IN_A.  But your real requirements might be to find mismatches in either direction where you might use:

 

if in_a=0 or in_b=0;

 

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1740 views
  • 0 likes
  • 3 in conversation