DATA Step, Macro, Functions and more

Need help

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

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: 7,468

Re: Need help

Posted in reply to Praveenit0808

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

 

View solution in original post


All Replies
Super Contributor
Posts: 439

Re: Need help

Posted in reply to Praveenit0808

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

Posted in reply to ChrisBrooks
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?


##- Please type your reply above this line. Simple formatting, no
attachments. -##
PROC Star
Posts: 735

Re: Need help

Posted in reply to Praveenit0808

I dont see the logic here, please provide more information.

Solution
‎05-08-2017 05:32 AM
PROC Star
Posts: 7,468

Re: Need help

Posted in reply to Praveenit0808

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: 283

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!

Trusted Advisor
Posts: 1,018

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

Re: Need help

Posted in reply to Praveenit0808
Yes thank so you much for your prompt response ....I'll definitely implement those steps in my program ...
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 315 views
  • 5 likes
  • 6 in conversation