Hi, I'm using the following code to calculate time difference between 2 variables: /* create new columns to calculate time differences and convert Time1 Time2 Time3 Time4 variables (columns have character values) */
data Ttimeslots2;
set Ttimeslots;
NewDraw1diff = input(Time1,time8.);
NewDraw2diff = input(Time2,time8.);
NewDraw3diff = input(Time3,time8.);
NewDraw4diff = input(Time4,time8.);
format NewDraw1diff NewDraw2diff NewDraw3diff NewDraw4diff time8.;
run; I have checked the variables attributes and the variables NewDraw1diff, NewDraw2diff, NewDraw3diff, and NewDraw4diff have time8. as format . Due to as error in variable Time1 in the original dataset, I have to correct the values in NewDraw1diff if a given condition is met based on the following code: data Ttimeslots3;
set Ttimeslots2;
if index(SP,'18C') then NewDraw1diff=Draw1-EDTIME;
format NewDraw1diff time8.;
run; Both Draw1 and EDTIME have time8. as format and informat and some rows have missing values. when I run the code above I get the following log messages: NOTE: Variable Draw1 is uninitialized. NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 56 at 400:58 NOTE: There were 1890 observations read from the data set TTIMESLOTS2. NOTE: The data set TTIMESLOTS3 has 1890 observations and 20 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.01 seconds It seems like the if statement is not property working and I can't figure out why. Does anyone know what's wrong with my code?
... View more