Suppose you are using SAS Studio (perhaps with the University Edition) and the statistical task you need to perform is not a supported option or feature in SAS. I know that sounds almost impossible because the statistical tasks in SAS Studio are so awesome. But, just in case you need to tweak a program or some task-generated code, let me show you how.
This example is taken from my latest book, Biostatistics by Example Using SAS Studio.
Editing the SAS Code Generated by the One-Way Frequencies Statistics Task
This is a good time to show you how to edit the SAS code produced by any of the SAS Studio tasks to customize a program. Click on the Code tab and the SAS program generated by the One-Way Frequencies request appears in the right-hand pane. It looks like this:
Figure 21: SAS Code Generated by the Request for One-Way Frequencies
proc freq data=SASHELP.HEART; tables Status Sex Chol_Status / nocum plots=(freqplot cumfreqplot); run;
This program uses the FREQ (frequency) procedure to produce the frequency tables and plots for the One-Way Frequencies task. You provide a list of variables that you want to analyze on the TABLES statement. Following this list you see a forward slash. A general rule in SAS procedures is that statement options (TABLES is considered a statement) are placed following a forward slash. Thus, NOCUM and PLOTS= are options that affect how the tables and charts appear. As you probably guessed, NOCUM is the instruction to omit cumulative statistics from the frequency table. Two plots, one a simple frequency plot and the other a cumulative frequency plot are requested by the two plot request (FREQPLOT and CUMFREQPLOT).
Let's modify this program in two ways: First, you want to add a customized title to the output; second, you want to omit the cumulative frequency plot. Here's how to do it:
The first step is to click on the EDIT button at the top right of the code pane (see Figure 22 below).
Figure 22: Clicking on the EDIT Button to Edit the Program
This action allows you to edit the task-produced program. To provide a customized title for the output, you use a TITLE statement. This consists of the keyword TITLE, followed by your title text, placed in single or double quotes. If any part of the title text contains a single quote, be sure to use double quotes to enclose the title. Next, move the cursor to CUMFREQPLOT and delete it. The resulting program should now look like this:
Figure 23: The Edited Program
title "Frequencies on Data from the Health Data Set"; proc freq data=SASHELP.HEART; tables Status SEX Chol_Status / nocum plots=(freqplot); run;
If you submit the program again, you will see your customized title and the bar chart showing cumulative frequencies will not be produced.
To learn more about how to use SAS Studio to run just about any statistical task, visit my SAS Press Author Page where you’ll learn more about my new Biostatistics book, as well as other titles I’ve authored.