Hello, I have a dataset (dat1) that has an identifier (numeric) as the first variable and n character variables. I also have another dataset (dat2) that maps each possible entry in all the character variables to a numeric value. data dat1;
input id cv1 $ cv2 $ cv3 $ cv4 $;
datalines;
111 aaa bbb ccc ccc
112 bbb bbb aaa ddd
113 aaa ccc ccc aaa
114 ddd bbb eee bbb
;
data dat2;
input cv $ nv;
datalines;
aaa 1
bbb 2
ccc 3
ddd 4
eee 5
; I'd like to turn all the character variables in dat1 to numeric using the mapping in dat2. Therefore, the resulting dataset in my example should be like: data dat3;
input id nv1 nv2 nv3 nv4;
datalines;
111 1 2 3 3
112 2 2 1 4
113 1 3 3 1
114 4 2 5 2
; Obviously, my true dat1 dataset is huge. Thanks.
... View more