Thursday, March 20, 2008

PUT, INPUT, and SUBSTR

/* input() function ---------------------Convert to Numberic
newVar = INPUT(oldVar, format);

put() function -----------------------Convert to Character
newVar = PUT(oldVar, format);

substr() function
*/

Data num;
A = 5;
B = '5';
C = A*B;
D = A*newB;

newB = input(B, 1.);
E = newB;
F = A*newB;

G = 98;
newD = put(G, 2.);

H1 = substr(newD, 2, 1);
H2 = substr('1998', 2);
run;

proc print data=num;
title "Data=put_input_substr";
run;


(OUTPUT)
Obs A B C D newB E F G newD H1 H2
1 5 5 25 . 5 5 25 98 98 8 998

No comments:

Post a Comment