1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

"case when" going wrong

Discussão em 'Outras Linguagens' iniciado por Stack, Fevereiro 23, 2021.

  1. Stack

    Stack Membro Participativo

    This is the code I made:

    proc SQL;
    create table want2 as
    select b.*
    , case when b.Outcome = "Answered" or
    b.Outcome = "Answerphone Message Left" or
    b.Outcome = "Answerphone Message Not Left" or
    b.Outcome = "No Answer"
    and
    a.Start_date <= b.Date < a.End_date
    and
    a.End_date <= b.Date+2
    then 1 else 0 END as Cured

    from have1 a, have2 b;
    quit;


    The datasets I'm working with are:

    data have1;
    infile datalines dlmstr=' | ';
    input ID Start_date :ddmmyy10. End_date :ddmmyy10.;
    format date start_date date9.;
    datalines;
    ID | Start_date | End_date
    1 | 01/01/2021 | 03/01/2021
    1 | 20/01/2021 | 21/01/2021
    2 | 05/01/2021 | 07/01/2021
    3 | 10/01/2021 | 30/01/2021
    3 | 25/01/2021 | 25/01/2021
    ;;;
    run;

    data have2;
    infile datalines dlmstr=' | ';
    input ID Date :ddmmyy10. Outcome ;
    format Date date9.;
    datalines;
    ID | Date | Outcome
    1 | 01/01/2021 | Answered
    2 | 05/01/2021 | Asnwerphone Message Left
    3 | 12/01/2021 | Answerphone Message Left
    3 | 25/01/2021 | No Answer
    ;;;
    run;


    In this case I should get the following:

    ID | Date | Outcome | Cured
    1 | 01/01/2021 | Answered | 1
    2 | 05/01/2021 | Asnwerphone Message Left | 1
    3 | 12/01/2021 | Answerphone Message Left | 0
    3 | 25/01/2021 | No Answer | 1


    But I'm actually only getting a "1" in the first row. And when I try it with my real data it's even worse.

    Any idea what might be wrong/missing?

    Continue reading...

Compartilhe esta Página