Presentation is loading. Please wait.

Presentation is loading. Please wait.

Summer SAS Workshop Lecture 2. Summer 20072 Summer SAS Workshop Lecture 2 I’ve got Data…how do I get started? Libname Review How do you do arithmetic.

Similar presentations


Presentation on theme: "Summer SAS Workshop Lecture 2. Summer 20072 Summer SAS Workshop Lecture 2 I’ve got Data…how do I get started? Libname Review How do you do arithmetic."— Presentation transcript:

1 Summer SAS Workshop Lecture 2

2 Summer 20072 Summer SAS Workshop Lecture 2 I’ve got Data…how do I get started? Libname Review How do you do arithmetic operations in SAS? Proc Means Proc Freq Proc Print Title Statements Libname Quiz More Practice!

3 Summer 20073 Part I of Lecture 2 The DATA Step Getting Data into SAS Libname Review Adding variables…doing arithmetic SAS Dates

4 Summer 20074 Get to know your data Before you do anything, review what format your data is in currently. Look at the number and type of variables, and number of observations (rows) you have in your data set(s). KNOW YOUR DATA! Before you can analyze your data with SAS software, your data must be in a form that SAS can read What are some ways to get data ready to analyze in SAS?

5 Summer 20075 What kind of data do you have? 1. Data that is already in the form of a SAS data set. Can right away be used for direct manipulation and analysis 2. Large files of external raw (non-SAS) data. Use Import functions, database copy software (ex: DBMSCopy), or other ways... 3. Small pieces of data that are not yet in a SAS data set. (What we have been doing so far-Internal Data) Enter as raw data directly into your Data Step (Keywords INPUT and CARDS)

6 Summer 20076 1) If you already have SAS data sets If you already have SAS data sets, first set up a library statement pointing to where your data is located. Libname heart ‘C:\DATA’; Next start using the data sets directly. Data icd9HF; Set heart.meps; If icd9 = 123.6; Run; Proc Freq Data = icd9HF; *Produce frequencies for Heart Failure patients by gender and race variables; Tables gender race; Run;

7 Summer 20077 Temporary vs. Permanent SAS Data Sets A two level name…a Temporary SAS data set is the one level name that we have been using: LibraryName.DataSetName Temporary SAS data sets will not exist when you shut down the instance of SAS in which they were created. Data new; Set AIDS; Run; First define a SAS Library (Libref)

8 Summer 20078 LIBNAME Statement Use this statement to define your SAS Library location before using your SAS data sets Example: LIBNAME ABC ‘C:\SASDATA’; Proc Means Data = ABC.EX4A; Var X Y Z; Run;

9 Summer 20079 INPUT statement example Data one; Input Name$ Bdate mmddyy10. Age Index; cards; Ann 04/22/1930 76 5 Cathy 08/06/1962 43 9 Rebecca 11/12/1983 22 2 ; Run; *Reading internal data to create SAS data set ‘one’;

10 Summer 200710 SAS Dates A SAS date is the number of days since January 1, 1960 DateSAS date value January 1, 1959 -365 January 1, 1960 0 January 1, 1961 366 January 1, 2001 14976

11 Summer 200711 Formatting Dates Informats – To read variables that are dates, you use formatted style input INPUT BirthDate MMDDYY10. Formats – If you print SAS date values, SAS will by default print the actual value, the number of days since January 1, 1960. The Format statement below tells SAS to print the variable BirthDate using the DDMMYY8. Format Format BirthDate DDMMYY8.

12 Summer 200712 Why are SAS dates done this way? SAS can use the SAS date to calculate many important things, just as it would any other numeric variable. AGE = INT ((ADMIT – DOB) / 365.25); (Calculates patient age at admission) LEN_STAY = DISCHRG – ADMIT +1; (Calculates the length of stay including the admission day and the discharge day)

13 Summer 200713 Lets Try this… Go to the website and unzip the Clinical2 SAS data file into your C:\DATA folder. Follow the steps (see slide 6) to make a copy of the data as a temporary SAS data set. Create a new variable from the HBeats variable (heart beats per 10 second count). Create and HR variable (beats per minute). Create a new Age at Baseline variable. Format the Birthdate variable as mmddyy10. and the BaselineDt variable as DATE9. Perform a Proc Contents of the new data set. Perform a Proc Print of the new data set.

14 Summer 200714 Difficult, dirty data…SAS doesn’t like it and neither do we

15 Summer 200715 Part II of Lecture 2 The DATA Step Proc Freq Proc Means Which variables from the clinical2 data set would you use in each for each of these Procs?

16 Summer 200716 PROC FREQ Shows the distribution of categorical data values PROC FREQ Data=datasetname; TABLES variable-combinations / option(s); RUN; One-way freq tables: TABLES YearsEducation; Cross-tabulation: TABLES Sex*YearsEducation;

17 Summer 200717 PROC MEANS Produces simple statistics such as the mean value, standard deviation, and minimum and maximum values PROC Means Data=datasetname; Var variablenames; RUN;

18 Summer 200718 Lets Perform these… Create a Proc Freq on the clinical2 data set. Choose the appropriate variables. Create a Proc Means on the clinical2 data set. Choose the appropriate variables.

19 Summer 200719 Part III of Lecture 2 Libname Quiz!

20 Summer 200720 Lets try to do HW 1 together… We will use the samples of TPA data to produce descriptive statistics and graphics in order to reproduce some of the stats in Tables 1 and 2 of the TPA paper. Readings: Readings for clarification of Libname etc. for start of classes: Cody Chapters 12-14


Download ppt "Summer SAS Workshop Lecture 2. Summer 20072 Summer SAS Workshop Lecture 2 I’ve got Data…how do I get started? Libname Review How do you do arithmetic."

Similar presentations


Ads by Google