Professional Documents
Culture Documents
SAS Learning Edition: The Basics: in This Chapter
SAS Learning Edition: The Basics: in This Chapter
Getting assistance within SAS Learning Edition is easy because you can get help on each task and you
can select the Help option from the main toolbar. In addition, you can get context-sensitive Help topics
with the F1 key. Because each keyword is hyperlinked within the Help options, you can drill down for
more detailed information.
• access
• manage
• analyze
• present
Data Management Query and display sales for the past month.
Because SAS/GRAPH maps and SAS/MDDB Server are not included in SAS Learning Edition, you will
not be able to work with multidimensional databases (MDDBs) or run Graph Map Chart tasks in SAS
Enterprise Guide.
SAS Learning Edition makes it easy for you to perform these tasks and get the results you need. Before
you begin, you will need to get your data into a form that SAS Learning Edition can use. The following
section describes SAS data sets and what they contain.
A SAS data set is a file storing a collection of data. A SAS data set is referenced by a name such as
Sales. If your data are stored in multiple SAS data sets, you can merge or join them to combine variables
into a single data set. This is important to remember because tasks can access only a single data set. (See
Chapter 2 for more details on tasks.) Also, SAS Learning Edition is designed for learning purposes
rather than for production applications, so there is a limit of processing only the first 1,000 observations
in your data set.
4 Data Management and Reporting Made Easy with SAS Learning Edition 2.0
The contents in a SAS data set can be visualized as a table of information organized in rows and
columns (like a Microsoft Excel spreadsheet). SAS uses the term variables to refer to columns and
observations to refer to rows. In Figure 1.1, PRODUCT is the first variable (column) and Shoes is the
first value in the first observation (row).
Observations
(Rows)
When referring to specific data values in SAS, you refer to the variables in the data set. Each variable
has a set of properties associated with it: name, type (either character or numeric), length, format,
informat, and label attributes. It is important to know the variable type since some tasks require numeric
variables. Variables that uniquely identify records are called key variables. Every data set should have
key variables. Common key variables should be specified when joining SAS data sets. This ensures that
records are correctly linked together so that information between the two files is not mismatched. The
example in Chapter 3 shows how easy it is to join files.
To obtain information on variable properties, as shown in Figure 1.2, select the data set and then right-
click to select properties. (For programmers, the results are similar to running the CONTENTS
procedure.)
Chapter 1: SAS Learning Edition: The Basics 5
In SAS Learning Edition, variable types are represented as symbols. SAS Learning Edition displays the
icon when assigning variable roles within tasks. In Figure 1.1, product, category, and customer are
character variables because they contain alphanumeric data while the other variables (year, month,
quarter, market, and sales) are numeric variables.
Often you need to display data values in a more meaningful representation to make reports and analyses
easier to read. SAS Learning Edition uses formats to do this. Examples of common formats include
DOLLARw.d, used to add a dollar sign ($) and decimal places to numbers when they are displayed and
COMMAw.d, used to add commas to numbers when they are displayed. In addition to all the predefined
formats available from SAS, you can create your own formats to display data values.
Both character and numeric variables can have formats as variable properties. For example, the
MARKET variable uses the MARKETV. format to display Catalog for the data value of 1 and to
display Retail for the data value of 2, and so on. Note that format names end with a period. In
addition, you can use formats to group a range of continuous values to obtain frequency of continuous
variables. See Chapter 3 for information on formats and how to create the SALESGRP variable and
format.
6 Data Management and Reporting Made Easy with SAS Learning Edition 2.0
This table is an example of output from using the MARKETV. format with the Market value.
Depending on the interactive dialog box that is displayed when selecting tasks, the required variable type
for each type of task role is indicated by the colored icons. This ensures that, for example, only numeric
variables are used for analysis. The table below contains data value examples for each variable type.
Character Variables
Character variables contain alphanumeric data that is case sensitive and can have embedded blanks.
Make sure that you have the correct spelling of the text when performing queries containing character
variables. For example: Shoes is not the same as shoes. In addition, embedded blanks can exist in
variables, for example South East has a blank between South and East. Note that although
character variables can store numeric values, this is not recommended because analysis can be
performed only on numeric variables.
Numeric Variables
Numeric variables contain numeric values that can be used in calculations. Numeric data can be
numbers, currency, date, or time data. It is best to store all sales and volume data in numeric
variables. SAS Learning Edition performs analysis only on numeric variables.
Chapter 1: SAS Learning Edition: The Basics 7
When using dates within queries, you need to specify dates as constants. Date constants must be
assigned in the format ‘DDMMMYY’D or ‘DDMMMYYYY’D, where the text is enclosed in single or
double quotes, and followed with the letter ‘D’.
Any mathematical operation can be applied to SAS date values to perform date calculations. The two
examples below are used to create a date constant and apply a date condition.
For more information about SAS data sets and variables, see the SAS Language Guide.
8 Data Management and Reporting Made Easy with SAS Learning Edition 2.0
SAS Learning Edition allows you to create more than one file type with a single task. As seen in Figure
1.4, select Tools ► Options from the toolbar and then the Results tab. There you can click on PDF,
RTF or Text output as result formats. By default, the results are saved as HTML files. This default
setting can be changed to another file type, if needed.
In addition to these file types, you can export your data to Microsoft Word or Microsoft Excel. Once
your data set is selected, you can create a Microsoft Word or Microsoft Excel file by selecting File ►
Send To from the toolbar. Figure 1.5 shows the Sales data set saved as an Excel file.
For more information on the Output Delivery System (ODS), see the References section for a list of SAS
papers on ODS, and visit the SAS ODS web site.
10 Data Management and Reporting Made Easy with SAS Learning Edition 2.0