Solved
Contributor
Posts: 46

# Match and list values in different columns

Hi Team,

Please assist in getting the desired output mentioned in the attached excel sheet

There are two tables.  The output should be like the right table (Yellow in colour).

Kind Regards

SHiva

Accepted Solutions
Solution
‎03-05-2014 06:46 AM
Contributor
Posts: 46

## Re: Match and list values in different columns

Amazing , thanks Richard  it works....

All Replies
Super Contributor
Posts: 644

## Re: Match and list values in different columns

Shiva

You need to explain the business logic behind the transformation you want.

Why are certain columns repeated in the yellow data?

Why are some cells set to null?

Is there any row level relationship between the apparent director-director, GM-GM and manager-manager entries, and if so, what is the logic?

Richard

Valued Guide
Posts: 2,191

## Re: Match and list values in different columns

Looks like a 2 stage exercise:

1. Taking advantage of the ordered input, DOW loops nested for each by-group level would simplfy the extract of the boss-underling pairs (just the relevant columns, controlled by keep lists as dataset options)  into separate streams of data which could be written to a separate table for each
2. A merge with no BY statement will place the separate streams (datasets) side-by-side.

If there might be situations where an individual had more than one boss, the streams should be sorted (NODUPKEY)

Super Contributor
Posts: 644

## Re: Match and list values in different columns

On closer inspection I agree with Peter's analysis that the yellow consists of 4 separate streams, each of which is the unique relationship between adjacent levels of this (surely bogus!) hierarchy.  However, to preserve the original order the data needs to be analysed using the notsorted option.  Here is the code for the first 2 cols

data cols_IJ ;

set have ;

by notsorted Director ;

keep ExDirector Director ;

if first.director ;

run ;

Richard

Solution
‎03-05-2014 06:46 AM
Contributor
Posts: 46

## Re: Match and list values in different columns

Amazing , thanks Richard  it works....

Contributor
Posts: 46

## Re: Match and list values in different columns

Thanks Peter for the steps ...

🔒 This topic is solved and locked.