data _null_; do i = 1 to 10; if i > 5 then put i=; end; run;
data _null_; do i = 1 to 9; if i > 5 then put i " > 5"; /* Note the semicolon! */ else put i " <= 5"; end; run;
data _null_; do i = 1 to 10; if i = 5 then do; put "------------"; put "-- i is 5 --"; put "------------"; end; end; run;
/* A subsetting if is an "if" without corresponding "then". */ data tq84_one; infile datalines; length col_2 $10; input col_1 col_2 ; datalines; 1 one 2 two 3 three 4 four 5 five 6 six 7 seven 8 eight 9 nine ; data tq84_two; set tq84_one; /* While the drop and keep statements control which variables make it into the output, the subsetting if determines which obserrvations go there. */ if col_2 gt 's'; run; proc print data=tq84_two; run;
data _null_; a = 42; if a = 42 then put 'a=42' /* Note the missing semicolon! */ else put 'a != 42'; run; /* NOTE: Variable else is uninitialized. NOTE: Variable put is uninitialized. a=42. . a != 42 NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds */