DATA Step, Macro, Functions and more

How to create a new variable with highest number from 3 other variables?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 82
Accepted Solution

How to create a new variable with highest number from 3 other variables?

Dear All,

I have a data file showed below:

ID  a1  b1  c1

1   23  35  61

2   76  71  10

3   90        60

4        31   50

5   70 42 

6   35 67  89

I want create a new variable 'd1' with highest number from a1, b1, c1.

Thanks for your help.


Accepted Solutions
Solution
‎11-03-2014 02:50 PM
Trusted Advisor
Posts: 1,204

Re: How to create a new variable with highest number from 3 other variables?

data have;

input ID  a1  b1  c1;

d1=max(of a1--c1);

datalines;

1   23  35  61

2   76  71  10

3   90  .   60

4    .  31  50

5   70  42  .

6   35  67  89

;

View solution in original post


All Replies
Super User
Posts: 5,256

Re: How to create a new variable with highest number from 3 other variables?

max()

Data never sleeps
Solution
‎11-03-2014 02:50 PM
Trusted Advisor
Posts: 1,204

Re: How to create a new variable with highest number from 3 other variables?

data have;

input ID  a1  b1  c1;

d1=max(of a1--c1);

datalines;

1   23  35  61

2   76  71  10

3   90  .   60

4    .  31  50

5   70  42  .

6   35  67  89

;

Frequent Contributor
Posts: 82

Re: How to create a new variable with highest number from 3 other variables?

Hi stat@sas and Linush,

Thanks so much for your quick response. I appreciate your help.

☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 222 views
  • 0 likes
  • 3 in conversation