Hi
Sometimes the variables that I import from Excel are character format and should be numeric format.
Rather than run
PROC CONTENTS DATA=test1
Each time
I used the following:
If year=2000 then do;
if var1=’’ then var1=’.’
Var1_num=input (var1,4.);
Drop var1;
Rename var1_num=var1;
Label var1_num=input (var1,4.);
if var2=’’ then var2=’.’
Var2_num=input(var2,4.);
Drop var2;
Rename var2_num=var2;
Label var2_num=input (var2,4.);
This works when the variables are text. The problem occurs if the variable(s) is numeric. If Var1 or Var2 is numeric, the content in the field becomes null.
Is there a condition statement that I could use to only change Var1 and Var2 to numeric if it is a character?
Thank you for your time.
DonaZ
Sometimes the variables that I import from Excel are character format and should be numeric format.
Rather than run
PROC CONTENTS DATA=test1
Each time
I used the following:
If year=2000 then do;
if var1=’’ then var1=’.’
Var1_num=input (var1,4.);
Drop var1;
Rename var1_num=var1;
Label var1_num=input (var1,4.);
if var2=’’ then var2=’.’
Var2_num=input(var2,4.);
Drop var2;
Rename var2_num=var2;
Label var2_num=input (var2,4.);
This works when the variables are text. The problem occurs if the variable(s) is numeric. If Var1 or Var2 is numeric, the content in the field becomes null.
Is there a condition statement that I could use to only change Var1 and Var2 to numeric if it is a character?
Thank you for your time.
DonaZ