Where Statement in SAS Programming Last Updated : 23 Jul, 2019 Comments Improve Suggest changes Like Article Like Report The WHERE statement is a substitute to IF statement when it comes to subsetting a data set. Syntax: WHERE (condition is true) => It refers to subsetting a dataset. Task1 : Suppose you want to select only section A students. You need to filter Section variable equals to A using where clause. SQL 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 Section EQ "A"; run; where section EQ "A" => This would tell SAS to select only section which is equals to values "A". You can also write where section = "A". This statement serves the same purpose. Output: LOGICAL OPERATORS Symbolic Mnemonic Meaning & AND Both conditions true | OR Either condition true ~ or ^ NOT Reverse the statement Task2: Suppose you want to select section A and B students. You need to filter Section variable equals to A or B using where clause. SQL 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 Section IN ("A" "B"); run; where section IN ("A" "B") => This would tell SAS to select those record where section is equals to either A or B values. Output: Comment More infoAdvertise with us Next Article How to drop variables from a dataset in SAS Programming? S ShubhamMaurya3 Follow Improve Article Tags : Software Engineering SAS Programming Similar Reads If-Then-Else statement in SAS Programming Comparison Operators used while using conditional statements. Symbol Mnemonic Meaning = EQ equals ^= or ~= NE not equal > GT greater than < LT less than >= GE greater than or equals <= LE less than or equals in IN selecting multiple values IF statement Syntax: IF (condition is true) = 3 min read Like Operator in SAS Programming LIKE Operator: Pattern Matching The LIKE operator used to select data by comparing the values of a character variable to a specified pattern. It is case sensitive. Task 1: To select all students with a name that starts with the letter S. There are two special characters patterns available for specif 1 min read How to Create or Modify a Variable in SAS Programming? This will help you to create or modify a variable. It is common to define a new variable based on the existing variable. Let's create a dataset In the code below, we are creating a dataset named as Example1 which is going to store on WORK(temporary) library. In this dataset, there would be a variabl 2 min read How to drop variables from a dataset in SAS Programming? This topic is regarding how to drop variables from a dataset in SAS. It includes various methods to delete variables from data. In SAS, there are two ways to drop variables: DROP = data set option DROP statement Let's start with creating a data set: SQL DATA outdata; INPUT roll_num gender $ class su 2 min read How to import External Data from Excel or Text file into SAS Programming? PROC IMPORT: It is a procedure to import external files into SAS. It automates importing process. There is no need to specify the variable type and variable-length to import an external file. It supports various formats of files such as excel, txt, etc. Importing an Excel File into SAS: The main key 1 min read Structured Analysis and Structured Design (SA/SD) Structured Analysis and Structured Design (SA/SD) is a diagrammatic notation that is designed to help people understand the system. The basic goal of SA/SD is to improve quality and reduce the risk of system failure. It establishes concrete management specifications and documentation. It focuses on 7 min read Like