190 likes | 347 Views
Introduction to SAS. Outline. Overview of SAS Getting Started with SAS Data Preparation Descriptive Statistics Basic Analysis Additional Help. NYU Data Services. Tutorials and support for academic software One-on-one consultation by appointment Data Services website:
E N D
Outline • Overview of SAS • Getting Started with SAS • Data Preparation • Descriptive Statistics • Basic Analysis • Additional Help
NYU Data Services • Tutorials and support for academic software • One-on-one consultation by appointment • Data Services website: • http://nyu.libguides.com/dataservices • Google “nyu data services” • Training tab • Slides and sample code • External resources
What is SAS? • SAS is a software application for storing, preparing, analyzing and reporting data. • Comparable software packages include: R, Stata, SPSS and MATLAB. • Not heavily used within academia but the standard within most industries.
Accessing SAS at NYU • In labs: • The Data Services lab • Various ITS labs • At home: • Purchase from the NYU Computer Store • Freely via the VCL (students only)
SAS’s Interface • Editor – Where SAS programs/scripts are written. • Log – The record of all executed commands. • Output – The results for executed commands. • Results – An order list of executed commands with linked shortcuts to output. • Explorer – Shows SAS Libraries and the datasets contained within them.
SAS Programs and Scripts • A SAS program is a text file containing instructions for the computer to run. • Programs can be created, opened, saved and run from the editor window. • SAS programs are neither space or case sensitive and all statements must end in a “;”. • Comments are initialized with “*”.
DATA and PROC Steps • DATA Step • Create a new or modify an existing dataset.DATA <dataset to be saved>; SET <dataset to reference>; <optional changes to dataset>;RUN; • PROC Step • Some task related to analysis/reporting.PROC <procedure> data=<data set>; <options>;RUN;
SAS Datasets and Libraries • The dataset is SAS’s only available data structure and is stored within SAS libraries. • A dataset is referenced by both its library and name: <library>.<dataset> • A LIBNAME in SAS is a shortcut reference to a Library and defined via:LIBNAME <name> “<location on computer>”;
Importing Datasets • SAS can import data that comes in most formats using a DATA or PROC step. • Two common methods for importing standard, delimited, data are as follows: DATA <new dataset>; INFILE <filename> DELIMITER=“<delimiter in file>”; INPUT <variables to input>;RUN; PROC IMPORT DATAFILE=<filename> OUT=<dataset> DBMS=<file type>;RUN;
Editing Data and Value Labels • A dataset can be edited in spreadsheet form by opening the dataset from the explorer window in “edit mode”. • Value labels are human-readable labels that are associated with the computer-readable numeric values of a variable. • Value labels can be created with the PROC FORMAT procedure and then applied to a procedure or dataset with the FORMAT option of a procedure or data set respectively.
If Then Statements • If/Then/Else statements are an essential method for control flow. They are commonly used within loops and functions as well as when recoding variables. IF <logical statement> THEN <block of code>;ELSE <block of code>;
Recoding/Computing Variables • Variables can be recoded by using IF/THEN/ELSE statements within a DATA step. • Similarly, new variables can be created using any combination of other variables within a mathematical expression within a DATA step.
Descriptive Statistics • SAS offers a variety of procedures to summarize data, a few common examples include: PROC FREQ, PROC MEANS and PROC UNIVARIATE. • Each procedure has a series of optional statements, such as VAR, WHERE and BY, and specifications that allow the output to be customized.
Graphics • SAS offers many different components for creating graphics, the most common of which is likely SAS/GRAPH. • Two common procedures are PROC BOXPLOTand PROC GPLOT. • Graphs can be saved using SAS ODS (Output Delivery System) or simply by right clicking and saving the graphic.
Statistical Procedures • SAS has procedures for conducting all common statistical tests, including: hypothesis tests, linear models, generalized linear models, time series analysis, multi-level models and many more. • For example t-tests can be conducted with PROC TTEST and linear models can be built with PROC REG.
Evaluation • Please help us improve this session and others by taking the following brief anonymous survey: bit.ly/nyusas2
Additional Help • The Data Services staff is available to answer SAS related questions. • Email: data.services@nyu.edu • Phone: (212)-998-3434 • Location: 5th Floor of Bobst Library • Please refer to the Data Services training page