BookmarkSubscribeRSS Feed
Dunne
Obsidian | Level 7

Hello,

 

Could anyone help me with? I want if any dx1-dx4 <=9 the generate a variate dx with the smallest dx (ex id=4 the smallest dx <-9 is of dx2). If all dx1-dx4 >9 then take the value of the smallest dx but not the value of 999.

 

Iddx1dx2dx3dx4
11210999
21011813
399910  
413145
5912 13

 

 

and I want the result looks like this

 

id dx
11
28
310
41
59

 

Thank you,

1 REPLY 1
Astounding
PROC Star

Why should ID 5 generate 9, and not 1?

 

Except for that, a short program would do:

 

data want;

set have;

dx = min(of dx1-dx4);

if dx=999 then dx=.;

run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 607 views
  • 0 likes
  • 2 in conversation