I have a dataset where some SAS Datastep logic are needed to populate the columns that are missing, or to be derived from exiting columns.
The dataset looks more like the below:
mpi v1 v2 v3......v9 v10 v11.....v50
001 a 1.324
002 c 0.876
003 f 11.9
004 r 5.7
005 b 3.3
. . .
. . .
n t 0.4
I actually developed the program below:
/*a*/
IF v2 ('a') AND 0 <= v11 <= 2 THEN DO;
v13 = 1;
v14 =20;
END;
IF v2 IN ('a') AND 2 < v11 <= 3.1 THEN DO;
v13 = 2;
v14 =40;
END;
IF v2 IN ('a') AND 3.1 < v11<= 5.3 THEN DO;
v13 = 3;
v14 =60; END;
IF v2 IN ('a') AND 5.3 < v11 <= 11.5 THEN DO;
v13 = 4;
v14 =80;
END;
IF v2 IN ('a') AND v11 > 11.5 THEN DO;
v13 = 5;
v14 =100;
END;
My request is that I need to write same program to populate v13 and v14 when v2 IN c
, f
, t
, r
, etc; but of different parameters for the bound in v11 (separate for c
, e
, g
,...) while v13 and v14 remain the same for the categories.
I would like to use SAS macro to get this done to avoid repetition of program. Can you help out on this?