Presentation is loading. Please wait.

Presentation is loading. Please wait.

Instructor: Raul Cruz-Cano

Similar presentations


Presentation on theme: "Instructor: Raul Cruz-Cano"— Presentation transcript:

1 Instructor: Raul Cruz-Cano raulcruz@umd.edu
EPIB 698C Lecture 2 Instructor: Raul Cruz-Cano 1 1

2 Note: http://www.oit.umd.edu/wheretogo/ + Room 1304
SAS Data Libraries A SAS library is simply a location where SAS data sets are stored Explorer window, click on “libraries”, there are at least three libraries: Sashelp, Sasuser and work. Sashelp and Sasuser contains information that controls your SAS session. Work is the default library, it is a temporary storage location for SAS data sets. Note: + Room 1304 2

3 Creating a new library Make the “Active libraries” window active (click Explorer, then click libraries) Choose “New” from the File menu or right click in the active libraries window and choose “New” from the pop-up menu 3

4 Creating a new library Type the name of the library in the box after name. This name must be eight characters or fewer, and contains only letters, numbers and underscore. In the path field, type in the complete path to the folder or directory where you want to save your data (or use Browse) 4

5 Creating a new library Another way to create a new library is to use the LIBNAME statement to associate the library with a directory accessible from your computer. LIBNAME mylib ‘H:/EPIB698A/week1’; associates the directory h:/EPIB698A/week1 with the name mylib. Mylib is known as a libref (a library reference) 5

6 Temporary/permanent SAS datasets
Every SAS dataset is stored in a SAS data library. By default all data sets created during a SAS session are temporary data sets and are deleted when you close SAS. All data sets associated with the library WORK are deleted at the end of the SAS session (they are temporary). A permanent data set is a data set that will not be deleted when SAS is exited. To create a permanent data set, simply use a different library name to create a data set.

7 To create Permanent SAS datasets
Code to create permanent SAS datasets libname yourlib ‘H:/EPIB698A/week1'; data yourlib.instructor; input name $ sex $ age; cards; Mike M 30 Wen F 29 Wei F 28 ; run;

8 To access Permanent SAS datasets
When you start a new SAS session, the permanent datasets can be accessed directly using libref. The name of the libref can be different from the name you used when creating the permanent data set. libname mylib ‘H:/EPIB698A/week1'; proc print data=mylib.instructor; run; Part 3 of Code 8

9 Viewing SAS data with SAS Explorer
Click the libraries icon in the Explorer window Click the library you want to see Click the data name to open a SAS data To go back to the previous window within Explorer, choose “up one level” from the view menu, or click the up one level button on the toolbar 9

10 Listing the properties of a SAS data set
Right click the SAS data icon Select “Properties” from the pop up menu If choose columns, SAS displays information about the columns (or variables) in the data set. 10

11 Using SAS system options
System options are parameters you can change that affect SAS: how it works, what the output look like, how much memory used, et al. You can see the list of system options and their current values by the following procedure: Proc options; run; 11

12 Change system options Options statement: it starts with the keyword “Options” and follows with a list of options you want to change with their values. Options Linesize=80 nodate; 12

13 Change system options Another way to change system options is to use the SAS system options window Type “Options” in the command bar or select it from the Tools pull-down menu: optionssystemlocate options from the left side of the screenright click specific options to change values 13

14 Common options Center|Nocenter: output centered or left-justified
Date|Nodate: today’s date appear in the output window Linesize=n: maximum length of output lines, possible values are 64 to 256. Number|Nonumber: page number for output window 14

15 Common options Pageno=n: starts numbering output pages with n
Pagesize=n: controls maximum number of lines per page of output. Possible values are 15 to 32767 15

16 PROC contents PROC contents prints the descriptive information about the data set and the variables in the data set Data set information: name, number of observations, number of variables, and date created Variable information: name, internal order, type, length, format/informat, and label Very useful for snapshot a data set Syntax: proc contents data=data_set_name; run;

17 TITLES Titles are descriptive headers SAS places at the top of each page of the OUT window. A title is set with the TITLE statement followed by a string of character. The string must be enclosed in single or double quotes. The maximum length for a string is 200 characters. If you want multiple line titles you can use the TITLE statement where the word title is followed by a number: title1 ‘EPIB 698C'; title2 'week1'; To clear the title setting simply execute title;

18 PROC print The PRINT procedure prints the observations in a SAS data set to the output window. Features: Autoformatting columns labeled with variable names or labels automatic accumulation and printing of subtotals and totals Syntax: proc print data=data_set_name options; var var1 var2 var3 var4; run; 18

19 PROC print (cont.) Useful options with PROC print:
double: double spaces the output noobs: suppresses observation numbers label: uses variable labels as column headings Id: suppresses observation numbers but put ID variable on the left-hand side of the page added statements for use in PROC print: prints different section at each level of “by” variable (needs a “sort” statement): by name_of_by_variable; sums variables at bottom of output: sum variable_list; 19

20 PROC print (cont.) The var statement
The var statement is used to specify the variables to process in a proc step. Not unique to proc print. Variables are usually processed in the order listed in the var statement. Only applies to a local proc step (not global) If no var statement is used, generally the procedure will process all the variables (or all the numeric variables if a calculation is performed). Part 4 of Code 20


Download ppt "Instructor: Raul Cruz-Cano"

Similar presentations


Ads by Google