turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- How to get table C in the easiest way?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-20-2017 12:40 PM

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;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-20-2017 12:49 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-20-2017 03:20 PM

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;