## Need help

Solved
Occasional Contributor
Posts: 6

# Need help

Can anyone help how to move values from one observation to another?

aa 11 101
bb 14 201
cc 13 303
dd 12 404
dd 17 505
;
run;
O/P like this
aa 12 101
aa 17 505
bb 14 201
cc 11 303
dd 13 404
;
run;

Can it be possible?

Accepted Solutions
Solution
‎05-08-2017 05:32 AM
PROC Star
Posts: 8,164

## Re: Need help

Is it possible? Almost anything is possible.

Do I know what you're trying to do? No!

Can one write code that produces what you want? Of course!

```data have;
input x \$ y z;
cards;
aa 11 101
bb 14 201
cc 13 303
dd 12 404
dd 17 505
;

data x(keep=x) y(keep=y y1) z(keep=z z1);
set have;
select (_n_);
when (1) do;
y1=4;
z1=1;
end;
when (2) do;
y1=3;
z1=3;
end;
when (3) do;
y1=5;
z1=4;
end;
when (4) do;
x='aa';
y1=1;
z1=5;
end;
otherwise do;
y1=2;
z1=2;
end;
end;
run;

proc sort data=x;
by x;
run;

proc sort data=y;
by y1;
run;

proc sort data=z;
by z1;
run;

data want (keep=x y z);
set x;
set y;
set z;
run;
```

Art, CEO, AnalystFinder.com

All Replies
Valued Guide
Posts: 593

## Re: Need help

Hi Praveen

I think you'll have to give us some more detail about the logic you want to use in order to get an answer to this

Occasional Contributor
Posts: 6

## Re: Need help

Thank you so much for helping me. However what exactly I need is. Here is
the problem:

Input name \$ status ;
Cards;
Aa active
Aa active
Aa active
Aa active
Aa active
Bb deactivated
Bb deactivated
Bb deactivated
Dd deactivated
Dd deactivated
Ee active
Ee active
Ee active
Cc active
Cc active
;
Run;

O/p should be like this

Aa active
Aa active
Aa active
Aa active
Aa active
Cc active
Cc active
Cc active
Ee active
Ee active
Ee active
Ee active
Ee active
Cc active
Cc active

How do we do that?

attachments. -##
PROC Star
Posts: 1,283

## Re: Need help

Solution
‎05-08-2017 05:32 AM
PROC Star
Posts: 8,164

## Re: Need help

Is it possible? Almost anything is possible.

Do I know what you're trying to do? No!

Can one write code that produces what you want? Of course!

```data have;
input x \$ y z;
cards;
aa 11 101
bb 14 201
cc 13 303
dd 12 404
dd 17 505
;

data x(keep=x) y(keep=y y1) z(keep=z z1);
set have;
select (_n_);
when (1) do;
y1=4;
z1=1;
end;
when (2) do;
y1=3;
z1=3;
end;
when (3) do;
y1=5;
z1=4;
end;
when (4) do;
x='aa';
y1=1;
z1=5;
end;
otherwise do;
y1=2;
z1=2;
end;
end;
run;

proc sort data=x;
by x;
run;

proc sort data=y;
by y1;
run;

proc sort data=z;
by z1;
run;

data want (keep=x y z);
set x;
set y;
set z;
run;
```

Art, CEO, AnalystFinder.com

PROC Star
Posts: 1,792

## Re: Need help

Is it possible? Almost anything is possible.

Do I know what you're trying to do? No!

Can one write code that produces what you want? Of course!

@art297  I love your sense of humor. I hope you are having a great weekend!

Posts: 1,337

## Re: Need help

This is an excellent response, and should be marked as the solution.

it's so good, we don't need to know what the problem is. ... and we don't.

Occasional Contributor
Posts: 6