Converting a variable from numeric to character
Earlier, we 'converted' a variable from character to numeric. Sometimes, we want to go the other way. Here is how:
data s1b (drop = i n5 n7 n10 n19 n21 n22 n36);Instead of using 'input', we use 'put'. Also, this example uses arrays to convert multiple variables at the same time. If the items had been consecutive, we could have shortened the code by using ranges (q1-q5).
set s1 (rename=(q5=n5 q7=n7 q10=n10 q19=n19 q21=n21 q22=n22 q36=n36));
array qq $ q5 q7 q10 q19 q21 q22 q36;
array nn n5 n7 n10 n19 n21 n22 n36;
do i = 1 to dim(qq);
qq[i] = put (nn[i], 8.0);
end;
run;
0 Comments:
Post a Comment
<< Home