I have the following table: f1 f2 f3 f4 f5 a1 a2 P x1 x2 a1 a2 N x3 x4 a1 a3 N x5 x6 a4 a6 P x7 x8
i want to convert to below: f1 f2 pf4 pf5 nf4 nf5 a1 a2 x1 x2 x3 x4 a1 a3 0 0 x5 x6 a4 a6 x7 x8 0 0 basically, when f3="P", I want f4 f5 to be moved to pf4 pf5 when f3="N", i want f4 f5 to be moved to nf4 nf5 when there is no "P" or "N" rows for the record, I want to fill in zeros in the corresponding fields. how to do it? Thanks, Zuohua