SAS IF-ELSE sintaxe

if else syntax
/* Com um statement apenas */
DATA new_dataset;
    SET old_dataset;

    IF variable1 = 'Yes' THEN result = 1;
    ELSE IF variable1 = 'No' THEN result = 0;
    ELSE result = .;

RUN;



/* Com mais de um statement */
DATA new_dataset;
    SET old_dataset;

    IF variable1 = 'Yes' THEN DO;
        result1 = 1;
        result2 = 2;
    END;
    ELSE IF variable1 = 'No' THEN DO;
        result1 = 0;
        result2 = 0;
    END;
    ELSE DO;
        PUT 'Invalid value for variable1.';
        STOP;
    END;

RUN;
if else syntax
    if x then delete;

    if status='OK' and type=3 then count+1;

    if age ne agecheck then delete;

    if x=0 then  
       if y ne 0 then put 'X ZERO, Y NONZERO'; 
       else put 'X ZERO, Y ZERO';
    else put 'X NONZERO';

    if answer=9 then
       do;
          answer=.;
          put 'INVALID ANSWER FOR ' id=;
       end;
    else
       do;
          answer=answer10;
          valid+1;
       end;

    data region;
       input city $ 1-30;
       if city='New York City'
          or city='Miami' then
          region='ATLANTIC COAST';
       else if city='San Francisco'
          or city='Los Angeles' then
             region='PACIFIC COAST';
       datalines;
    ...more data lines...
    ;