6 views

Uploaded by madh83

SAS

- Sandeep Oduru
- SAS Sort Accum Total
- Debug
- Don't Be a SAS Dinosaur
- Introduction to Sas Programming
- Base Unit Test Paper_2solution
- Anon Resume
- 2012 2013 Format File Instructions
- Ch 12 Producing Summary Reports - Exercises
- Sas InformationMap Document
- SAS Online Training
- 28743095 SAS Interview Questions
- All Course Details-ATI
- 56514
- Software Docs SAS Enterprise Guide
- Tips for Manipulating Data in SAS
- SAS® 9.4 CDISC ProcedureUser’s GuideSAS
- Where vs if Statement
- Modulo Superior Pad
- SAS HDR Case Study Aug2017

You are on page 1of 30

SAS WORKSHOP

Yuexiao Dong

Department of Statistics Fox School of Business & Management Temple University

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Outline

Introduction to SAS Using SAS for Windows SAS data handling: Data Step Read data Useful statements SAS Procedures

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Outline

Introduction to SAS Using SAS for Windows SAS data handling: Data Step Read data Useful statements SAS Procedures

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Objectives

This workshop is designed for beginning users who want to get started with the program, and experienced users who want to get to know the new generation of SAS system. Through this workshop, you may Get accustomed to the SAS system; Understand how SAS processes a program; Get familiar with the data handling process; Manage data sets in SAS; Perform simple statistical analysis.

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

What is SAS

SAS stands for Statistical Analysis System. It is both a statistical language and a system that performs sophisticated data management and statistical analysis. SAS is available in multiple computing environments, including Windows, Mac, UNIX, etc. SAS for Windows will do every task that other editions of SAS do, it is easy to use, and is more powerful.

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Outline

Introduction to SAS Using SAS for Windows SAS data handling: Data Step Read data Useful statements SAS Procedures

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Explorer/Result window, provide control and organization of the SAS objects and system output; Editor window, color coding, edit program; Log window, diagnostics of the programming syntax and hints for debugging; Output window, show results output by SAS procedures, blank if program does not go through correctly; Many other windows, such as Library window, Filename window, Options window, Graphic windows, etc; Keys window is a road map to SAS windows and gives you shortcuts to different windows; Type "keys" in the command box at the upper left corner.

Yuexiao Dong SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Entering SAS statements.

Each statement can go on several lines, but it MUST end with a semi-colon; Conventions on Windows operations are applicable, cut, paste and save for example; Format of display, cascade or tile under Window option at the menu bar.

Submitting SAS statements. Saving SAS statements. Retrieve SAS programs. File option at the menu bar. Ending a SAS session.

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Outline

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

A DATA step consists of a group of statements that reads ASCII text data (in a computer le) or existing SAS data sets in order to create a new SAS data set. DATA one; INPUT x y z @@; CARDS; 123456789 ; RUN; PROC PRINT DATA=one; RUN;

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

This sample SAS program creates a temporary data set using the CARDS statement to read in the in-line data. The DATA statement denes a temporary data set; The INPUT statement denes the variables and their formats; The CARDS statement gives instruction to start reading in the data that follow. The RUN statement ends this session of the program and submits for processing; Data manipulation must be done in a DATA step and cannot be done in a PROC step.

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

DATA cars1; INPUT make $ model $ mpg weight price; CARDS; AMC Concord 22 2930 4099 AMC Pacer 17 3350 4749 Buick Electra 15 4080 7827 ; PROC PRINT DATA=cars1(obs=1); RUN; It is usually a good idea to print the rst few cases of your dataset to check that things were read correctly. $ means the previous variable is characteristic.

Yuexiao Dong SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

DATA cars2; INPUT make $ 1-5 model $ 6-12 mpg 13-14 weight 15-18 price 19-22; CARDS; AMC Concord2229304099 AMC Pacer 1733504749 AMC Spirit 2226403799 BuickCentury2032504816 BuickElectra1540807827 ; RUN;

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Heres what the data in the le cars3.txt look like: AMC Concord 22 2930 4099 AMC Pacer 17 3350 4749 AMC Spirit 22 2640 3799 Buick Century 20 3250 4816 Buick Electra 15 4080 7827 To read the data from cars3.txt into SAS, use the following syntax: DATA cars3; INFILE "c : \cars3.txt"; INPUT make $ model $ mpg weight price; RUN;

Yuexiao Dong SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Heres what the data in the le cars4.txt look like: AMC,Concord,22,2930,4099 AMC,Pacer,17,3350,4749 AMC,Spirit,22,2640,3799 Buick,Century,20,3250,4816 Buick,Electra,15,4080,7827 To read the data from cars4.txt into SAS, use the following syntax: DATA cars4; INFILE "c : \cars4.txt" delimiter= , ; INPUT make $ model $ mpg weight price; RUN;

Yuexiao Dong SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Heres what the data in the le cars5.txt look like:

AMC Concord2229304099 AMC Pacer 1733504749 AMC Spirit 2226403799 BuickCentury2032504816 BuickElectra1540807827

To read the data from cars5.txt into SAS, use the following syntax: DATA cars5; INFILE "c : \cars5.txt"; INPUT make $ 1-5 model $ 6-12 mpg 13-14 weight 15-18 price 19-22; RUN;

Yuexiao Dong SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Previous examples use CARDS or INFILE to create temporary data set. Now we create a permanent data set is and store under the library project1. LIBNAME myproj c : \sasworkshop ; DATA myproj.cars1; SET cars1; PROC PRINT; RUN; A SAS library is like a special SAS pointer to a location where your SAS les are stored. To create a library, we use LIBNAME nickname name-of-directory; where nickname should begin with either a letter or an underscore and having no more than 8 characters.

Yuexiao Dong SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

SET/DROP/KEEP/RENAME

DATA temp1; SET cars1(DROP=make model); RENAME price=newprice; PROC PRINT; RUN; DATA temp2(KEEP=price); SET cars1(DROP=make model); PROC PRINT; RUN; DATA temp3; SET cars1; IF upcase(make) EQ BUICK ; PROC PRINT; VAR make model;RUN;

Yuexiao Dong SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

IF-THEN/ELSE statements

LIBNAME myproj c : \sasworkshop ; DATA myproj.new; SET cars1; IF mpg GE 20 THEN fuelefciency = high ; ELSE fuelefciency= low ; RUN; PROC PRINT; RUN; Here we create a new variable fuelefciency. Then we can print the most recently created data set.

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Subsetting datasets

DATA high low; SET myproj.new; IF fuelefciency = high THEN output high; ELSE output low; RUN; The IF-THEN statements draw subsets from the data set by the fuelefciency variable. We have created two temporary datasets named high and low. What is the print result next? PROC PRINT; RUN;

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Outline

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

General syntax

A PROCedure step calls a SAS procedure to analyze or process a SAS dataset. The PROC step begins with a PROC statement and ends with a RUN statement. All of the statistical procedures require the input of a SAS data set. The general syntax for a PROC step is: PROC name [DATA=dataset] [options]; [other PROC-specic statements;] [BY varlist;] RUN;

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

General syntax

PROC name [DATA=dataset] [options]; [other PROC-specic statements;] [BY varlist;] RUN; SAS keywords are in uppercase; User-supplied words are in lowercase; Options are in brackets [ ] . Note that you do not type the brackets when programming.

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

General syntax

A SAS program can contain any number of DATA and PROC steps. Once a dataset has been created, it can be processed by any subsequent DATA or PROC step; All SAS statements start with a keyword (DATA, INPUT, PROC, etc.) and end with a semicolon; Uppercase and lowercase are equivalent, except inside quote marks ( sex = m is not the same as sex = M).

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Useful procedures

PROC PRINT; check the data being read by SAS; PROC CONTENTS [data = _all_]; descriptions of the contents of one or more les; PROC SORT; BY var; RUN; sort the data by the specied variable var; PROC MEANS; compute statistics for an entire SAS data set or for groups of observations in the data set.

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Useful procedures

PROC UNIVARIATE provides detail on the distribution of one variable. DATA Measures; INPUT Diameter @@; CARDS; 5.501 5.251 5.404 5.366 5.445 5.576 5.607 5.200 5.977 ... ; RUN; title Normal Q-Q Plot for Diameters; PROC UNIVARIATE data=Measures noprint; QQPLOT Diameter / normal; RUN;

Yuexiao Dong SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

PROC UNIVARIATE

6.4 6.2 6.0

Diameter

N al Quantiles orm

Yuexiao Dong

SAS WORKSHOP

Introduction to SAS Using SAS for Windows SAS data handling: Data Step SAS Procedures

Some references

The Little SAS Book: A Primer, Third Edition (Paperback), by Lora D. Delwiche and Susan J. Slaughter. SAS Certication Prep Guide: Base Programming (Paperback), by SAS Institute. http://www.uc.edu/sashtml/stat/index.htm http://ftp.sas.com/samples/A59216

Yuexiao Dong

SAS WORKSHOP

- Sandeep OduruUploaded bykavitha221
- SAS Sort Accum TotalUploaded bysarath.annapareddy
- DebugUploaded bySkyvalley81
- Don't Be a SAS DinosaurUploaded bysamir_aitidir
- Introduction to Sas ProgrammingUploaded bybakoma
- Base Unit Test Paper_2solutionUploaded byANUP KUMAR DAS
- Anon ResumeUploaded byJF
- 2012 2013 Format File InstructionsUploaded byr4aden
- Ch 12 Producing Summary Reports - ExercisesUploaded bytushar
- Sas InformationMap DocumentUploaded byクマー ヴィーン
- SAS Online TrainingUploaded bylisa0909
- 28743095 SAS Interview QuestionsUploaded byThomas Emmanuel
- All Course Details-ATIUploaded bytanwar_at
- 56514Uploaded byVinay Kumar
- Software Docs SAS Enterprise GuideUploaded byNicolas Frazier
- Tips for Manipulating Data in SASUploaded byim keh
- SAS® 9.4 CDISC ProcedureUser’s GuideSASUploaded byNagesh Khandare
- Where vs if StatementUploaded byVipul Gupta
- Modulo Superior PadUploaded byJuan Vera
- SAS HDR Case Study Aug2017Uploaded byAkhil Arora
- CHASEUploaded byAbdi Jones
- ODS LAYOUTUploaded byfa_cooper
- R programingUploaded byNikhil Cn
- Using SAS to Build Customer Level Datasets for Predictive Modeling Scott ShockleyUploaded byArima Prabu
- Sas Connect9 4 UsersguideUploaded byRocío Vázquez
- Print Hariharan HariUploaded byapi-3806285
- NBN Strategic Analysis - V1Uploaded byAnonymous j2CbWu
- An Overview of Graphical Representation of Dairy Science Data Using Sas and EgUploaded byosman
- SAS Introduction to Time Series Forecasting-libreUploaded bypalani
- imsgsUploaded bysomsan87

- routefinder_mapinfoUploaded bydaohuyhp
- 12 Miscellaneous ParsingUploaded byLika Ch
- BDC With Table Control for Customer MasterUploaded byAshish Mohapatra
- BOM_INVENTORY_COMPS_INTERFACEUploaded bysachin_mahendra2533
- Classic HFM Activites document.docxUploaded byDeepakreachme525
- Base de Datos VideojuegosUploaded byAlejandroGalindoGutierrez
- ISO 8583 Message FormatUploaded bySatya Panda
- MonitorTm Help ManualUploaded byDang Khoa
- Symbols and Status Text in Authorization MaintenanceUploaded byManasaLatha
- Configuration Guide OASM 2 0 SP6Uploaded bysapabap403
- How to Configure a Loytec LIP Router Into a Hawk 01Uploaded bymystique_8
- Jungle FlasherUploaded bymiller617854543
- Esper ReferenceUploaded byAnkur Bhartiya
- Programming Crystal Reports With ASPUploaded byash_mzn1
- SAPUI5 and Fiori Interview QuestionsUploaded byKarthik Ks
- 102_2010_0_b-1.pdfUploaded byFreePDFs
- Introduction to Form PersonalizationUploaded bySaurabh Sonkusare
- Binary ArithmeticUploaded byborntruce
- 09-2 Structural Pattern - ProxyUploaded byKarthikesankannan
- Software Estimation Ch-2Uploaded byPratik Bhandirge
- Label Security 11gR2Uploaded bymanish nashikkr
- Mca2010 Slm Unit 01Uploaded byamritrathour
- TMA ResumeUploaded byNguyễn Trung Kiên
- UMAR - Ubiquitous Mobile Augmented RealityUploaded bybluestone55
- HR ABAPUploaded bydamodar1987
- CS4001 FuzzySets Systems Properties Lect 2Uploaded byKoteswaraRaoB
- ESRI.extending.arcobjectsUploaded bydaghhgqe1651651
- Java AnsUploaded byNaveen Idx
- x86_1Uploaded bymanoprabha
- QualNet 5.0.2 InstallationGuideUploaded byHưng Ngô