BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PierreYvesILY
Pyrite | Level 9

Hello,

 

I need to programm the following:

RSKNKM
BR01
<= 1,6A+A+
<= 2,6AA+
<= 3BA+
<= 3,4CA+
<= 3,6CA
<= 3,8CA
<= 4CB
<= 4,2DC
<= 4,6DD
> 4,6XX

 

BR values are in the 1st column

NKM values are in the 2nd line, column 2 and 3.

The result is RSK and is given in the matrix (BR, NKM).

For instance: BR <= 4 and NKM = 0 is RSK = C.

 

I started in the proc sql step with the code:

(case

when BR = . and NKM = 0 then '??'

when BR <= 1.6 and NKM = 0 then 'A+'

when BR <= 2.6 and NKM = 0 then 'A '

when BR <= 3.0 and NKM = 0 then 'B '

when BR <= 3.6 and NKM = 0 then 'C '

when BR <= 4.2 and NKM = 0 then 'D '

when BR > 4.2 and NKM = 0 then 'X '

else '??' end) as RSK,

 

but it doesn't work properly. In Addition, I have to programm the case and NKM = 1, with different values of BR as in the table.

 

What is the right way to do?

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @PierreYvesILY,

 

I would create two formats and apply them using the PUTN function, e.g.:

proc format;
value rsk0f
low  - 1.6  = 'A+'
1.6< - 2.6  = 'A'
/* ... */
4.6< - high = 'X'
other       = '??';

value rsk1f
low  - 3.4  = 'A+'
/* ... */
4.6< - high = 'X'
other       = '??';
run;

data want;
set have;
length rsk $2;
rsk=putn(br,cats('rsk',nkm,'f'));
run;

 

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hello @PierreYvesILY,

 

I would create two formats and apply them using the PUTN function, e.g.:

proc format;
value rsk0f
low  - 1.6  = 'A+'
1.6< - 2.6  = 'A'
/* ... */
4.6< - high = 'X'
other       = '??';

value rsk1f
low  - 3.4  = 'A+'
/* ... */
4.6< - high = 'X'
other       = '??';
run;

data want;
set have;
length rsk $2;
rsk=putn(br,cats('rsk',nkm,'f'));
run;

 

PierreYvesILY
Pyrite | Level 9

super! danke, es funktioniert total gut.

 

VG aus München

PY