Dear all,
I have data in a txt file (see attached).
First, I read them to SAS:
data have;
infile 'mypath\sample.txt' dlm='09'x dsd lrecl=4096 truncover firstobs=2 termstr=LF;
input Mark Name :$20. Country :$20. Type :$20. Id var1 :$20. var2 :$20. var3 :$20. var4 :$20. var5 :$20.
var6 :$20. var7 :$20. var8 :$20. var9 :$20. var10 :$20. var11 :$20.;
run;
Now, I want to convert var11 to numeric:
data want;
set have;
new=compress(translate(var11,"", '"n.a.", ')); /* remove all unnecessary characters*/
new1=input(new, 12.); /* convert it to numeric*/
new2=new*1; /* alternative way*/
keep var11 new:;
run;
The problem is that it does not convert the variable. However, when I use var2 instead of var11, everything is fine
data want1;
set have;
new=compress(translate(var2,"", '"n.a.", ')); /* remove all unnecessary characters, here I use var2*/
new1=input(new, 12.); /* convert it to numeric*/
new2=new*1; /* alternative way*/
keep var2 new:;
run;
Why converting var11 does not work?
... View more