Contains and Between-And operators in SAS Programming - GeeksforGeeks

23 Jul, 2019
BETWEEN-AND Operator: Between Two NumbersTask 1: Suppose you want to select scores whose values are greater than or equal to 50 and less than or equal to 90.data readin;input name $ Section $ Score;cards;Raj  A 80Atul A 77Priya B 45Sandeep A 95Rahul C 84Shreya C 44;run;  data readin1;set readin;where Score between 50 and 90;run;where Score between 50 and 90 => This would tell SAS to select values through 50 and 90 (not 51 to 89).OutputThis can also be written like:where Score GE 50 and Score LE 90;CONTAINS Operator: Searching specific characterTask 2: Suppose you want to select only those observations in which students’ name contain ‘hil’.data readin;input name $ Section $ Score;cards;Raj  A 80Atul A 77Priya B 45Sandeep A 95Rahil C 84Sahil B 44;run;  data readin1;set readin;where name contains 'hil';run;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
BETWEEN-AND Operator: Between Two NumbersTask 1: Suppose you want to select scores whose values are greater than or equal to 50 and less than or equal to 90.data readin;input name $ Section $ Score;cards;Raj  A 80Atul A 77Priya B 45Sandeep A 95Rahul C 84Shreya C 44;run;  data readin1;set readin;where Score between 50 and 90;run;where Score between 50 and 90 => This would tell SAS to select values through 50 and 90 (not 51 to 89).OutputThis can also be written like:where Score GE 50 and Score LE 90;
data readin;input name $ Section $ Score;cards;Raj  A 80Atul A 77Priya B 45Sandeep A 95Rahul C 84Shreya C 44;run;  data readin1;set readin;where Score between 50 and 90;run;
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;
CONTAINS Operator: Searching specific characterTask 2: Suppose you want to select only those observations in which students’ name contain ‘hil’.data readin;input name $ Section $ Score;cards;Raj  A 80Atul A 77Priya B 45Sandeep A 95Rahil C 84Sahil B 44;run;  data readin1;set readin;where name contains 'hil';run;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
CONTAINS Operator: Searching specific character
Task 2: Suppose you want to select only those observations in which students’ name contain ‘hil’.
data readin;input name $ Section $ Score;cards;Raj  A 80Atul A 77Priya B 45Sandeep A 95Rahil C 84Sahil B 44;run;  data readin1;set readin;where name contains 'hil';run;
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
SAS Programming
Programming Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Programming Languages to Learn in 2022
Shallow Copy and Deep Copy in C++
Difference between Shallow and Deep copy of a class
Decorators with parameters in Python
C# | Data Types
Advantages and Disadvantages of OOP
Kotlin Array
Prolog | An Introduction
Java Swing | JComboBox with examples
Program to calculate Electricity Bill