In this post, we will create a simple report using the cars2 data set that we created in the previous exercise.
To Remove Obs Column – add noobs to the PROC PRINT statement.
To Print only Selected Variables – use VAR Statement and add only the variables you need. The VAR statement selects the variables that one needs in the reports and determines their order.
To Specify a Condition for Selecting Observations – use WHERE statement. We can also apply WHERE statement to the variables that are not listed in VAR statement. It can be used for both numeric and character variables. However there are some rules for using WHERE statement for character variables: i. enclose the value of the variable in quotation marks. ii. write the value with lowercase and uppercase letter as exactly mentioned in the data set. The following comparison operators can be used with WHERE statement:
|= or eq||equal to|
|^= or ne||not equal to|
|> or gt||greater than|
|< or lt||less than|
|>= or ge||greater than or equal to|
|<= or le||less than or equal to|
Suppose we want to list the Audi cars that are priced less than or equal to $30,000, we will use a logical operator AND. We use logical operators with WHERE statement whenever we want to add multiple conditions.
There are two logical operators that can be used with WHERE statement:
|&||AND||If both expressions are true, compound expression is true.|
|! or | or ¦||OR||If either of expressions are true, compound expression is true.|
When both AND and OR statements are encountered by SAS, it processes the conditions in a specific order: First, the expressions joined by AND are processed. Then, the expressions joined by OR are processed.