Contains and Between-And operators in SAS Programming

  1. BETWEEN-AND Operator: Between Two Numbers

    Task 1: Suppose you want to select scores whose values are greater than or equal to 50 and less than or equal to 90.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    data readin;
    input name $ Section $ Score;
    cards;
    Raj  A 80
    Atul A 77
    Priya B 45
    Sandeep A 95
    Rahul C 84
    Shreya C 44
    ;
    run;
      
    data readin1;
    set readin;
    where Score between 50 and 90;
    run;

    chevron_right

    
    

    where Score between 50 and 90 => This would tell SAS to select values through 50 and 90 (not 51 to 89).

    Output

    This can also be written like:

    where Score GE 50 and Score LE 90;

  2. CONTAINS Operator: Searching specific character

    Task 2: Suppose you want to select only those observations in which students’ name contain ‘hil’.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    data readin;
    input name $ Section $ Score;
    cards;
    Raj  A 80
    Atul A 77
    Priya B 45
    Sandeep A 95
    Rahil C 84
    Sahil B 44
    ;
    run;
      
    data readin1;
    set readin;
    where name contains 'hil';
    run;

    chevron_right

    
    

    where name contains ‘hil’ => This would tell SAS to select observations having the values Rahil, Sahil for the variable NAME.

    Note: The CONTAINS operator is case sensitive.

    Output



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.