11 Chapter 2: Working with Data in a Project 2.1 Introduction to Tabular Data 2.2 Accessing Local...
-
Upload
anthony-flynn -
Category
Documents
-
view
218 -
download
0
Transcript of 11 Chapter 2: Working with Data in a Project 2.1 Introduction to Tabular Data 2.2 Accessing Local...
11
Chapter 2: Working with Data in a Project
2.1 Introduction to Tabular Data2.1 Introduction to Tabular Data
2.2 Accessing Local Data
2.3 Importing Text Files
2.4 Editing Tables in the Data Grid
3
Common Data FormatsSAS Enterprise Guide can read and use data from a variety of different formats.
3
Microsoft Excel Microsoft Excel spreadsheetsspreadsheets
JMP, SPSS, JMP, SPSS, and Stata filesand Stata files
HTML tablesHTML tablesODBC-ODBC-compliant datacompliant data
OLE DB OLE DB provider’s filesprovider’s files
Microsoft Microsoft AccessAccess tablestables
Fixed-width Fixed-width and delimited and delimited
text filestext files
SAS data setsSAS data sets
5
2.01 Multiple Answer PollWhich types of data do you work with?
a. Microsoft Excel
b. Microsoft Access
c. DBMS tables (such as Oracle or DB2)
d. SAS data sets
e. Text files (delimited files)
f. Other
5
6
SAS Data Set
6
A SAS data set (or table) is a rectangular table of rows and columns.
Rows(observations)
Columns (variables)
8
SAS Data Set
8
A column’s type is either character (string) or numeric. The type plays a role in determining the length.
Charactervalues are1 to 32,767characters
(bytes) long.
Numeric values are 8 bytesof floating point storage:
Numeric Currency Date (days from 01JAN1960) Time (seconds from midnight)
9
SAS Data Set
9
A format is used to control how values are displayed. Formats do not affect how values are stored.
Format: MMDDYYWidth: 10Stored value: 15766
Format: DOLLARWidth: 8Decimal Places: 2Stored value: 234.60
12
2.02 Multiple Choice PollWhich of the following variable attributes is not required?
a. Name
b. Type
c. Length
d. Format
12
13
2.02 Multiple Choice Poll – Correct AnswerWhich of the following variable attributes is not required?
a. Name
b. Type
c. Length
d. Format
13
14
SAS Data Set PropertiesViewing a data set’s properties enables you to examine the data set and column attributes.
14
16
2.03 Multiple Choice PollRight-click on the employee_organization data set in the project and select Properties Columns. What is the length of the variable Job_Title?
a. 8
b. 9
c. 25
d. 40
16
17
2.03 Multiple Choice Poll – Correct AnswerRight-click on the employee_organization data set in the project and select Properties Columns. What is the length of the variable Job_Title?
a. 8
b. 9
c. 25
d. 40
17
18
Missing ValuesIf a data value is not present for a column in a particular row, it is considered missing. A missing character value is displayed as a blank. A missing numeric value is displayed as a period or dot.
18
.
1919
Chapter 2: Working with Data in a Project
2.1 Introduction to Tabular Data
2.2 Accessing Local Data2.2 Accessing Local Data
2.3 Importing Text Files
2.4 Editing Tables in the Data Grid
21
Business Scenario
21
Orion maintains a list of products in a Microsoft Excel file named products.xlsx. To use this data in SAS Enterprise Guide, it must be imported into a SAS data set.
22
Importing Structured Data Not from SASThe Import Data wizard enables you to create SAS data sets from text, HTML, or PC-based data files (including Microsoft Excel and Microsoft Access).
22
23
Step 1: Specify DataThe first step is to confirm the source data and designate the output SAS data set name and storage location.
23
Verify the fileto be imported.
Change the name andstorage location for theoutput SAS data set.
24
Step 2: Select Data SourceChoose the data to be read and indicate whether the first row contains column names.
24
26
2.04 Multiple Answer PollIf the Rename columns to comply with SAS naming conventions. option is selected, which column headings would be modified in the imported data set?
a. Product_Categoryb. Product Namec. Discount%d. Supplier-Country
26
27
2.04 Multiple Answer Poll – Correct AnswersIf the Rename columns to comply with SAS naming conventions. option is selected, which column headings would be modified in the imported data set?
a. Product_Categoryb. Product Namec. Discount%d. Supplier-Country
Spaces and special symbols will be replaced with an underscore.
27
28
Step 3: Define Field Attributes Set column attributes for columns included in the imported SAS data set.
28
30
Import Data ResultsThe new SAS data set is created and accessible via the Project Tree or Process Flow.
30
31
Updating ResultsThe Import Data wizard can be rerun or modified from the Output Data tab.
31
Use the buttonto refresh theoutput data set.
Use Modify Task to reopenthe Import Data wizard andmake changes.
32
Adding a Local Excel Spreadsheet to the Project
This demonstration illustrates how to add a local Excel spreadsheet to the project.
32
3333
Chapter 2: Working with Data in a Project
2.1 Introduction to Tabular Data
2.2 Accessing Local Data
2.3 Importing Text Files2.3 Importing Text Files
2.4 Editing Tables in the Data Grid
35
Business ScenarioOrion Star has a fixed-width text file named orders. To use the data in the text file, it must be imported into a SAS data set.
35
36
Business ScenarioThe SAS data set must have the following attributes: Name the data set orders. Exclude the Employee_ID column. Assign column names based on the first row of the
text file. Format Profit as a currency value. Format Discount with a percent sign.
36
37
Import Data WizardTo your computer, a text file is only strings of characters. SAS Enterprise Guide requires that the data be structured with rows and columns (observations and variables).
37
38
Import Data WizardThe Import Data wizard can be used to convert a text file into a customized SAS data set.
38
40
2.07 QuizWhat do you need to tell SAS Enterprise Guide about this file in order to provide the necessary structure to create a SAS data set?
40
41
2.07 Quiz – Correct AnswerWhat do you need to tell SAS Enterprise Guide about this file in order to provide the necessary structure to create a SAS data set? where each column is located in the text file which columns to read in the name of each column whether the first row contains column headings the type of data in each column
– character– numeric (currency, date, time)
how much storage space to allocate how to read and format the data values
41
42
Adding Data from a Fixed-Width Text File
This demonstration illustrates using the Import Data task to read a text file.
42
4646
Chapter 2: Working with Data in a Project
2.1 Introduction to Tabular Data
2.2 Accessing Local Data
2.3 Importing Text Files
2.4 Editing Tables in the Data Grid 2.4 Editing Tables in the Data Grid
47
Objectives Use the Data Grid to delete columns and rows. Use the Data Grid to modify column attributes
and sort a data set. Use the Expression Builder to create columns.
47
48
Business ScenarioA data manager at Orion Star wants to permanently modify the orders data set to include a column named
Total_Invoice that represents the sum of
Total_Retail_Price and Shipping.
48
49
Data GridWhen you add a data set to a project, the Data Grid’s default behavior is to display the data automatically in read-only mode.
Actions available in the Data Grid in read-only mode include the following: browsing SAS data sets and other data sources resizing row and column widths for better viewing copying rows and columns to paste into a new or
existing SAS data set hiding rows and columns from view holding rows and columns while scrolling
49
50
Data GridActions available in the Data Grid in update mode are limited to SAS data sets and include all actions available in read-only mode, as well as the ability to do the following: edit data values change the names of columns apply labels and formats to columns delete rows and columns sort by multiple columns in ascending or descending
order create new columns and add rows
50
When you modify a data set through the Data Grid,you change the actual data values in the data set.
51
Column PropertiesRight-click on a column and select Properties to modify the column name, label, type, and format.
51
52
Insert a ColumnTo permanently add a column, right-click on the existing column where the new column should be added and select Insert Column….
52
53
Expression Builder: Creating a ColumnUse the Advanced Expression Builder to provide an expression to build a new column.
53