SAS PROC PRINT WHERE Statement Example

The SAS PROC PRINT procedure is a powerful tool for outputting data in a variety of formats. One of its most useful features is the WHERE statement, which allows you to filter the data that is printed. In this article, we'll explore the SAS PROC PRINT WHERE statement with examples to help you understand and implement this functionality.

a blue and white poster with instructions to write an exam sheet for the department's office
a blue and white poster with instructions to write an exam sheet for the department's office

Before diving into the examples, let's briefly understand the syntax of the WHERE statement in PROC PRINT. The basic syntax is as follows:

42 Effective Capability Statement Templates (+ Examples)
42 Effective Capability Statement Templates (+ Examples)

```sas PROC PRINT DATA=dataset WHERE expression; RUN; ```

Understanding the WHERE Statement

The WHERE statement in PROC PRINT filters the data based on a logical expression. This expression can be a simple comparison, a range, or even a complex combination of conditions using AND, OR, and NOT operators.

SAT grammar cheat sheet
SAT grammar cheat sheet

In this section, we'll explore two sub-topics: simple WHERE conditions and compound WHERE conditions.

Simple WHERE Conditions

FREE 13+ Method Statement Samples & Templates in PDF, Word
FREE 13+ Method Statement Samples & Templates in PDF, Word

Simple WHERE conditions involve a single comparison between a variable and a value or another variable. Here's an example:

```sas DATA sales; INPUT product sales_amount; DATALINES; A 100 B 200 C 150 D 250 E 300 ; RUN; PROC PRINT DATA=sales WHERE sales_amount > 200; RUN; ```

In this example, only the observations where `sales_amount` is greater than 200 will be printed. The output will be:

``` product sales_amount ------- ----------- D 250 E 300 ```

Compound WHERE Conditions

Statement of Account Sample and Template
Statement of Account Sample and Template

Compound WHERE conditions combine multiple simple conditions using AND, OR, and NOT operators. Here's an example:

```sas PROC PRINT DATA=sales WHERE (product = 'B' OR product = 'D') AND sales_amount > 150; RUN; ```

In this case, the output will include observations where the `product` is either 'B' or 'D', and `sales_amount` is greater than 150. The output will be:

``` product sales_amount ------- ----------- B 200 D 250 ```

Using WHERE with Multiple Variables

an info sheet describing how saps partner functions are used to help people understand what they want
an info sheet describing how saps partner functions are used to help people understand what they want

You can also use the WHERE statement to filter data based on multiple variables. In this section, we'll explore two sub-topics: using multiple variables in the WHERE statement and using the IN operator.

Using Multiple Variables in the WHERE Statement

Dental Student Memes, What The Dentist Sees Meme, Dental Memes Humor Truths, Dentist Appointment Meme, I Want To Work, School College, Health Science, Professions, Pediatrics
Dental Student Memes, What The Dentist Sees Meme, Dental Memes Humor Truths, Dentist Appointment Meme, I Want To Work, School College, Health Science, Professions, Pediatrics
How and Where to Print Printables From Etsy
How and Where to Print Printables From Etsy
a sample statement for an account form is shown in this document, which shows the amount of
a sample statement for an account form is shown in this document, which shows the amount of
Download SARS Special Power of Attorney (SPPOA) Form - FormFactory
Download SARS Special Power of Attorney (SPPOA) Form - FormFactory
the project scope statement is shown in green and blue, as well as an image of what
the project scope statement is shown in green and blue, as well as an image of what
an info sheet showing the process for saps to be used in different areas of the world
an info sheet showing the process for saps to be used in different areas of the world
SAP Cross Company Code Postings
SAP Cross Company Code Postings
Problem Statement Templates | 13+ Free Word, Excel & PDF Formats, Samples, Examples, and Forms
Problem Statement Templates | 13+ Free Word, Excel & PDF Formats, Samples, Examples, and Forms
2015-2026 Form PH SSS E-4 - Blank Fillable Template | Fill Out, Print & Download PDF | pdfFiller
2015-2026 Form PH SSS E-4 - Blank Fillable Template | Fill Out, Print & Download PDF | pdfFiller
a printable form for a personal statement
a printable form for a personal statement
what saas product really needs
what saas product really needs
4 Free Resources for SAT® Prep. - HSLDA Online Academy
4 Free Resources for SAT® Prep. - HSLDA Online Academy
a diagram showing the process of using sapp to create an application for data processing
a diagram showing the process of using sapp to create an application for data processing
a flyer for an accounting system that is designed to look like a laptop computer
a flyer for an accounting system that is designed to look like a laptop computer
The 6 Types of Posts Every SaaS Company Should Be Publishing (Stop Being Invisible)
The 6 Types of Posts Every SaaS Company Should Be Publishing (Stop Being Invisible)
Problem Statement | Templates at allbusinesstemplates.com
Problem Statement | Templates at allbusinesstemplates.com
10 Must-Know Tips in Writing SAP Functional Specification Documents
10 Must-Know Tips in Writing SAP Functional Specification Documents
the statement of purpose in this paper
the statement of purpose in this paper
Statement of Account Templates | 12+ Free Docs, Xlsx & PDF Formats, Samples, Examples, and Forms
Statement of Account Templates | 12+ Free Docs, Xlsx & PDF Formats, Samples, Examples, and Forms
Pick up your pencils: A sneak peek at the new SAT
Pick up your pencils: A sneak peek at the new SAT

You can use multiple variables in the WHERE statement by combining them with AND or OR operators. Here's an example:

```sas PROC PRINT DATA=sales WHERE (product = 'C' OR product = 'E') AND sales_amount > 180; RUN; ```

The output will include observations where the `product` is either 'C' or 'E', and `sales_amount` is greater than 180.

Using the IN Operator

The IN operator allows you to test if a variable is in a list of values. Here's an example:

```sas PROC PRINT DATA=sales WHERE product IN ('A', 'C', 'E'); RUN; ```

In this case, the output will include observations where the `product` is either 'A', 'C', or 'E'.

In conclusion, the SAS PROC PRINT WHERE statement is a powerful tool for filtering data and controlling the output of your SAS programs. By mastering the WHERE statement, you can efficiently extract and present the information you need from your datasets. Happy coding!