Download presentation
Presentation is loading. Please wait.
1
Chapter 2: Working with Data in a Project
2.1 Understanding SAS Data Structure 2.2 Importing Data Files Other Than SAS Files 2.3 Accessing Data via SAS Libraries
2
Chapter 2: Working with Data in a Project
2.1 Understanding SAS Data Structure 2.2 Importing Data Files Other Than SAS Files 2.3 Accessing Data via SAS Libraries
3
Objectives State the definition of a SAS data set.
State how data is stored in a SAS data set.
4
Common Data Formats SAS Enterprise Guide can read and use data from a variety of different formats including the following: SAS data sets Microsoft Excel and Access DBMS tables Text files JMP HTML SPSS
6
2.01 Multiple Answer Poll Which types of data do you work with?
Microsoft Excel Microsoft Access DBMS tables (such as Oracle or DB2) SAS data sets Text files (delimited files) Other Type answer here
7
SAS Data Set A SAS data set (or table) is a rectangular table of rows and columns. Rows (observations) Columns (variables)
8
Names can be 1 to 32 characters long.
SAS Data Set All columns must have a name, type, and length. It is recommended that column names also start with a letter or underscore include only letters, underscores, and numbers. Names can be 1 to 32 characters long.
9
Character values are 1 to 32,767 characters (bytes) long.
SAS Data Set A column’s type is either character (string) or numeric. The type plays a role in determining the length. Character values are 1 to 32,767 characters (bytes) long. Numeric values are 8 bytes of floating point storage: Numeric Currency Date (days from 01JAN1960) Time (seconds from midnight)
10
SAS Data Set A format is used to control how values are displayed. Formats do not affect how values are stored. Format: DOLLAR Width: 10 Decimal Places: 2 Stored value: Format: DATE Width: 9 Stored value: 16497
11
Formats
13
2.02 Multiple Choice Poll Which of the following variable attributes is not required? Name Type Length Format Type answer here
14
2.02 Multiple Choice Poll – Correct Answer
Which of the following variable attributes is not required? Name Type Length Format Type answer here
15
SAS Data Set Properties
Viewing a data set’s properties enables you to examine the data set and column attributes.
17
2.03 Multiple Choice Poll Open the employee_organization data set. Click the Properties button on the toolbar and select Columns. What is the length of the variable Job_Title? 8 9 25 40 Type answer here
18
2.03 Multiple Choice Poll – Correct Answer
Open the employee_organization data set. Click the Properties button on the toolbar and select Columns. What is the length of the variable Job_Title? 8 9 25 40 Type answer here
19
Missing Values If 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. .
20
Chapter 2: Working with Data in a Project
2.1 Understanding SAS Data Structure 2.2 Importing Data Files Other Than SAS Files 2.3 Accessing Data via SAS Libraries
21
Objectives Import a Microsoft Excel spreadsheet and create a SAS data set. Import a fixed-width text file and create a SAS data set. View the properties of the data.
22
Business Scenario Orion maintains a Microsoft Excel file named products and a fixed-width text file named orders. To use these data sources in SAS Enterprise Guide, they must be imported into SAS data sets.
23
Adding Data to a Project
When a SAS data set is added to a project, SAS Enterprise Guide is able to read and open the data immediately. A shortcut to the data is added to the project.
25
2.04 Quiz Select File Open Data… and navigate to the location of the course data if necessary. What happens when you open the products Excel file? Type answer here
26
2.04 Quiz – Correct Answer Select File Open Data… and navigate to the location of the course data if necessary. What happens when you open the products Excel file? The Import Data task automatically opens. Type answer here
27
Importing Data Not in a SAS Data Set
The Import Data wizard can be used to read text, HTML, or PC-based data files (including Microsoft Excel and Microsoft Access) and to create SAS data sets.
28
Step 1: Specify Data The first step is to confirm the source data and designate the output SAS data set name and storage location. Verify the file to be imported. Change the name and storage location for the output SAS data set.
29
Step 2: Select Data Source
When you read from structured data such as Microsoft Excel or Access, choose the data to be read and indicate whether the first row contains field names.
30
Step 2: Select Data Source
When you read from non-structured data such as a text file, choose the text format and indicate how the columns should be split.
32
2.05 Multiple Answer Poll If the Rename columns to comply with SAS naming conventions. option is selected, which column headings would be modified in the imported data set? Product_Category Product Name Discount% Supplier-Country Type answer here
33
2.05 Multiple Answer Poll – Correct Answers
If the Rename columns to comply with SAS naming conventions. option is selected, which column headings would be modified in the imported data set? Product_Category Product Name Discount% Supplier-Country Spaces and special symbols are replaced with an underscore. Type answer here
34
Step 3: Define Field Attributes
Set column attributes for columns included in the imported SAS data set.
35
Step 4: Advanced Options
Select any applicable advanced options.
36
Import Data Results The new SAS data set is created and accessible via the Project Tree or Process Flow window. It is important to point out that data sources referenced in an EG project are not actually stored within the project. The small arrow in the lower left-hand side of the icon is meant to remind the user that any data source, whether added to a project or created within the project, is stored external to the project. The icon merely represents a pointer to the data source. On the other hand, objects such as reports are stored as part of the EG project.
37
Updating Results The Import Data wizard can be rerun or modified from the Output Data tab. Use the button to refresh the output data set. Use Modify Task to reopen the Import Data wizard and make changes.
38
Using the Import Data Task
This demonstration illustrates how import a Microsoft Excel and fixed-width text file to create SAS data sets.
40
Setup for the Quiz (Live Web Only)
Import the Products Excel file and create a SAS data set: Create a new project. Add the Products Excel file. (Select File Open Data….) In step 1, verify that the output SAS data set is Products. In step 2, verify that the ProductList worksheet is highlighted and that First row of range contains field names is selected. Accept the default settings in step 3 and 4. Select Finish to create the new SAS data set.
41
2.06 Quiz What do you select to make a change in the Import Data task, such as change the name of the first variable? Type answer here
42
2.06 Quiz – Correct Answer What do you select to make a change in the Import Data task, such as change the name of the first variable? Modify Task Type answer here
43
Using the Import Data Task (continued)
This demonstration illustrates how import a Microsoft Excel and fixed-width text file to create SAS data sets.
45
Exercise This exercise reinforces the concepts discussed previously.
46
Would like a review of the exercises?
Please answer with your Yes or No seat indicator.
47
Chapter 2: Working with Data in a Project
2.1 Understanding SAS Data Structure 2.2 Importing Data Files Other Than SAS Files 2.3 Accessing Data via SAS Libraries
48
Objectives Identify remote data sources. Access a remote server.
Add remote data to a project.
49
Business Scenario Orion Star wants to use SAS Enterprise Guide to access a DBMS table on a remote server. The table includes information about customer orders.
50
Transparent Access to Remote Data
UNIX Local User z/OS Mainframe Windows Server
51
SAS Libraries A SAS library is a collection of files that are defined, recognized, and accessible by SAS. Libraries can be used to access SAS or DBMS data. Example: The ORION library can be defined to reference all SAS data sets in s:\workshop.
52
Opening Files from a SAS Server or Folder
The Open Data dialog box enables you to access files from servers where SAS is installed and configured to run with SAS Enterprise Guide. The Libraries icon enables access to predefined folders containing SAS or DBMS data sources. The Files icon enables access to the directories available on the server.
53
Accessing Data via SAS Servers
The Resources pane provides another method to view and access all of your available files and data sources. SAS Folders are used in the platform for SAS Business Analytics.
55
2.07 Quiz Select View Server List or click the Server List icon in the Resources pane below the Project Tree. Expand Servers your server name Libraries. What libraries are listed? Type answer here
56
2.07 Quiz – Correct Answer Select View Server List or click the Server List icon in the Resources pane below the Project Tree. Expand Servers your server name Libraries. What libraries are listed? Possible answers: Work , Sashelp, Sasuser, EGTASK, MAPS Type answer here
57
2.08 Quiz In the Server List window, expand the Files icon. What is listed? Type answer here
58
2.08 Quiz – Correct Answer In the Server List window, expand the Files icon. What is listed? The file structure of the server Type answer here
59
Defining SAS Libraries
SAS libraries are typically set up by your SAS administrator. However, the Assign Project Library wizard can be used to define libraries to SAS or DBMS data sources for which you have Read permission.
60
Accessing Remote Data After you add a data source to a project, by default it automatically opens in the data grid.
61
Adding a Data Set via a SAS Library
This demonstration illustrates how to define a project library and add a data set to the project via the library definition.
64
Setup for the Poll Use the Assign Project Library task to create the ORION library and point to the location of the course data. (Select Tools Assign Project Library….) Include the ACCESS=READONLY option in step 3 of the task. View the ORION library in the Server List. If you do not see the library or the data sets, right-click Servers and select Refresh. Right-click on the travel_expenses table in the Server List and select Copy. Right-click on the Work library and select Paste. Double-click the travel_expenses table in the Work library to add it to the project.
65
2.09 Poll Right-click travel_expenses in the Process Flow or Project Tree window and select Delete. Is the table deleted from the library? Yes No Type answer here
66
2.09 Poll – Correct Answer Right-click travel_expenses in the Process Flow or Project Tree window and select Delete. Is the table deleted from the library? Yes No Only the shortcut is removed from the project, but the table remains in the library. Type answer here
67
2.10 Poll Right-click travel_expenses under the Work library in the Server List and select Delete. Are you able to delete the table? Yes No Type answer here
68
2.10 Poll – Correct Answer Right-click travel_expenses under the Work library in the Server List and select Delete. Are you able to delete the table? Yes No If you have Write access to a library and the data sets within, you can move, copy, and delete files in the Server List. These actions cannot be undone, so be careful! Type answer here
69
2.11 Poll Right-click travel_expenses under the ORION library in the Server List and select Delete. Are you able to delete the table? Yes No Type answer here
70
2.11 Poll – Correct Answer Right-click travel_expenses under the ORION library in the Server List and select Delete. Are you able to delete the table? Yes No Because you used the ACCESS=READONLY option when you defined the ORION library, you cannot make changes to the contents. Type answer here
72
Chapter Review What are the two types of columns in a SAS data set? What happens to a date? How is it stored? What SAS item is used to control the way that a data value is displayed in a report?
73
Chapter Review Answers
What are the two types of columns in a SAS data set? What happens to a date? How is it stored? What SAS item is used to control the way that a data value is displayed in a report? The two types are character and numeric. A date is stored as an integer representing the number of days between January 1, 1960 and a specific date. A SAS format is used to control how a data value is displayed. For example, the DOLLARw.d format displays a numeric value with dollar signs, commas, and the specified number of decimals.
74
Chapter Review True or False: When you access data via the Import Data task, a new SAS data set is created. True or False: When you add a data source to a project by selecting File Open Data, the data is saved in the project. What type of files can you import with the Import Data task?
75
Chapter Review Answers
True or False: When you access data via the Import Data task, a new SAS data set is created. True True or False: When you add a data source to a project by selecting File Open Data, the data is saved in the project. What type of files can you import with the Import Data task? False: A pointer to the data source is saved in the project. You can import Microsoft Excel and Access data as well as text files.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.