Intermediate SAS: Working with Data
|
|
- Miles Hampton
- 6 years ago
- Views:
Transcription
1 Intermediate SAS: Working with Data OIT Technical Support Services oit.wvu.edu/training/classmat/sas/ Table of Contents Getting set up for the Intermediate SAS workshop:... 2 Working with Dates... 3 More with Formats and Functions... 4 Working with Data Files... 5 Concatenating data files:... 5 Merging files:... 5 Activity: Merge vs Set... 5 Creating a subset of a data file... 6 Using a procedure to create a new data file... 7 Creating system files... 7 System Options... 8 Error Messages... 9 Common Syntax Errors... 9 Common Data Errors... 9 Reference... 9 Examples of Problem Semicolons: Other Possible Errors: Copyright 2002 West Virginia University
2 Getting set up for the Intermediate SAS workshop: Review of importing an Excel spreadsheet: computers.xls 1. Go to the File menu and select Import Data. 2. Make sure the data source says Excel 97 or 2000 spreadsheet. 3. Click on Next. Then click on the Browse button to find your file. 4. You are looking for computers.xls on your Desktop. When you find the file, click on the Open button to make it appear in the box. Click on Next to continue. 5. Type computer as the member name. Click on Next. 6. Click on Finish. You should be returned to your program editor Enter the following SAS program in your Enhanced Program editor. DATA people; INFILE 'C:\Windows\Desktop\people.txt'; INPUT idno $ bday $ wt paid score gender $; PROC PRINT; RUN; 1. Save this program on your desktop as people.sas. 2. Run the program and review the results. 2 Intermediate SAS
3 Working with Dates 1. Use a date format to read in a date value. Modify your input statement to change the $ after bday to a date informat: INPUT idno bday MMDDYY8.... is a column pointer telling SAS where to start reading the variable. MMDDYY8. is a date format. The 8 tells SAS to allow 8 columns (this gives room for the slashes). Run your program again. What happens? DATE formats DATE7. 05AUG60 DATE9. 05AUG1960 MMDDYY MMDDYY8. 08/05/60 DDMMYY8. 05/08/60 WORDDATE18. August 5, 1960 DOWNAME9. Friday JULIAN NENGO10. S.35/08/05 2. Use a date output format to print out date values. Add a new line after the input statement to reformat bday's date value: FORMAT bday MMDDYY8. ; Run your program again. What happens? Try some of the other DATE formats from the box instead of MMDDYY8. 3. Use the TODAY() function to find out today s date value. Go back to your program and add another line (after FORMAT statement): ANOW = TODAY(); The TODAY function returns today's date as a date/time value (the number of days since 1/1/60). Do not type anything between the parentheses. 4. Compute the person's age Add another line: AGE = (ANOW DATE)/365 ; Run your program again. You should have some new columns of information. DATA people; INFILE 'C:\Windows\Desktop\people.txt'; INPUT idno bday MMDDYY8. wt paid score gender $; FORMAT bday MMDDYY8.; anow=today(); age=(anow-bday)/365; PROC PRINT; RUN; Intermediate SAS 3
4 More with Formats and Functions 1. Use functions to compute square roots, log transformations, maximum, and averages Go back your program and add some new lines to your data step: X = SQRT(SCORE); Y = LOG(SCORE); Z = LOG10(WT); W = MEAN(WT,PAID,SCORE); BIG = MAX(WT,PAID,SCORE); diff = z y; Add a VAR statement after your PROC PRINT; and before your RUN; statement. VAR IDNO X Y Z W BIG; 2. Output formats With the following, don't forget to allow columns for punctuation marks (commas, periods, $, hyphens). Add the following statement to your data step: FORMAT PAID DOLLAR10.2 SCORE ROMAN8. WT 6.2; Add the following procedure to the end and run just that by highlighting it first: proc print; var idno paid score; run; Obs idno paid score $55, XCIV $45, LXXXVIII DATA people; age=(anow-bday)/365; x = SQRT(score); y = LOG(score); z = LOG10(paid); w = MEAN(wt,paid,score); big = MAX(wt,paid,score); diff=z-y; PROC PRINT; VAR idno x y z w big; RUN; 3. Using a format to create categories for frequency tables At the top of your program, add: PROC FORMAT; VALUE grade LOW-59='F' 60-69='D' 70-79='C' 80-89='B' 90-HIGH='A'; VALUE grp LOW-35000='Low' HIGH='High'; At the end of your program, add: PROC FREQ; TABLES score*paid; FORMAT SCORE grade. PAID grp.; RUN; 4 Intermediate SAS
5 Working with Data Files Concatenating data files: Files usually have the same variables and different observations. DATA BOTH; SET one two; DATA BOTH; SET one two; BY IDNO; * will interleave based on id number; * files one & two were sorted by id in a previous step; Merging files: files usually have the same experimental units and different variables DATA COMBINE; MERGE one two; * one-to-one matching; DATA COMBINE; MERGE one two; BY idno; * will use id variable to match observations together; * datasets must be in same sorted order; Activity: Merge vs Set Go to the Enhanced Program Editor Clear your editor: Edit > Clear All Open combine.sas (from the desktop) and run it. Data ONE; input ID YEAR AMT; cards; PROC SORT; BY ID; Data TWO; input ID YEAR AMT; cards; PROC SORT; BY ID; DATA BOTH; SET ONE TWO; PROC PRINT; TITLE 'SET'; DATA BOTH; SET ONE TWO; by ID; PROC PRINT; TITLE 'SET BY'; DATA BOTH; MERGE ONE TWO; PROC PRINT; TITLE 'MERGE'; DATA BOTH; MERGE ONE TWO; by ID; PROC PRINT; TITLE 'MERGE BY'; RUN; Draw a line from each Data step to the correct output. When you are done, clear the contents of all windows. Intermediate SAS 5
6 Creating a subset of a data file Selecting Observations DATA MALES; SET people; IF gender='m'; *subsetting IF; or DATA MALES; SET people; IF gender='f' THEN DELETE; Create 2 data files in one data step: DATA MALES FEMALES; SET people; *set allows you to re-process an existing data set; IF gender='m' then OUTPUT MALES; ELSE IF gender='f' then OUTPUT FEMALES; Selecting Variables DATA new; SET people; DROP score; or DATA another; SET people; KEEP IDNO AGE PAID; Summary of new statements: DELETE: throw out observation DROP: throw out variable(s) IF : (subsetting if): keep observation if condition is true KEEP: retain only these variables OUTPUT: write an observation out to a data set 6 Intermediate SAS
7 Using a procedure to create a new data file PROC MEANS NOPRINT data=people; BY date; VAR paid score; OUTPUT OUT=newfile MEAN=avgpd avgscor N=n1 n2; PROC PRINT data=newfile; VAR date avgpd avgscor n1 n2; RUN; New option for proc means statement: NOPRINT: don't do typical means results New statement: OUTPUT OUTPUT OUT=filename statistic=new_varname(s); PROC REG data=people; MODEL score=wt; OUTPUT OUT=new2 P=predscor R=resid; PROC PLOT data=new2; PLOT predscor*score; PLOT resid*idno; RUN; QUIT; P creates variable for predicted values; R for residuals (actual predicted) Creating system files LIBNAME more 'C:\Windows\Desktop\'; DATA more.stuff; SET people; This will create a file named: stuff.sas7bdat in the folder you specified. To use existing system files in new programs: 1. First include the appropriate LIBNAME statement 2. Then specify the library and member name: PROC xxx DATA=lib.member; DATA new; SET lib.member; IF var=value; PROC FREQ DATA=more.stuff; DATA subset; SET more.stuff; IF gender='f'; Intermediate SAS 7
8 System Options The OPTIONS statement can appear anywhere in a SAS program and can appear more than once. OPTIONS set stay in effect until they are reset later in the program. NONOTES suppress notes and warning messages in SAS LOG NODATE suppress date on OUTPUT NONUMBER suppress page number on OUTPUT NOCENTER left justify the OUTPUT PS: PageSize how many lines per page (OUTPUT) LS: LineSize how many characters per line (OUTPUT) Default values for SAS/Windows: OPTIONS NOTES DATE NUMBER CENTER PS=67 LS=84; OPTIONS NODATE NOCENTER PS=84 LS=72; To switch back to the defaults, delete the no prefix: OPTIONS NOTES DATE NUMBER CENTER; FIRSTOBS which observation to start on OBS number of observations to read in To read only a portion of a huge data file (lines 100 through 500, inclusive): OPTIONS FIRSTOBS=100 OBS=500; To see what the setting is for a particular option: proc options option=linesize; run; General Tips Make backup copies of programs and data on multiple media. Keep records of what you do to your data and your programs Write comments in your program to document what you are doing: /* comment */ Use /* */ comments to block out statements you do not wish to run at this time When possible, keep data in a separate file and use an infile statement Use formats and labels to make output easier to read If variable names are like: q1, q2, q3... Q10, you can refer to them as q1-q10 You can specify a list of variables from input statement: bday -- gender; You can factor table requests in proc freq: tables age*(paid wt score); 8 Intermediate SAS
9 Error Messages Common Syntax Errors leaving out ; putting ; in instream data misspelling/mistyping variable name or option invalid variable name forgetting closing quote mark forgetting END; statement (needed when using DO) Common Data Errors using wrong input format specifying wrong columns O vs 0 (oh vs zero) extra blank line not using. for missing data in free-format list format using.. (multiple periods) for missing data Reference SAS Guide to Problem Solving and Error Messages (Version 5 Edition), ISBN Intermediate SAS 9
10 Examples of Problem Semicolons: data; input x y z cards; proc print; ERROR : Statement is not valid or it is used out of proper order. ERROR: No CARDS or INFILE statement. 7 data 18 input x y z; 19 cards; NOTE: The data set WORK.INPUT has 1 observations and 0 variables. NOTE: The data set WORK.X has 1 observations and 0 variables. NOTE: The data set WORK.Y has 1 observations and 0 variables. NOTE: The data set WORK.Z has 1 observations and 0 variables. 23 proc print; NOTE: No variables in data set WORK.Z. 26 data ; 27 input x y z; 28 cards; NOTE: The data set WORK.DATA3 has 2 observations and 3 variables. NOTE: The DATA statement used 0.88 seconds ; ERROR : Statement is not valid or it is used out of proper order. Other Possible Errors: 44 data ; 45 input x y z; 46 q=sqrt(x); NOTE: Invalid argument to function SQRT at line 46 column 3. X=-1 Y=2 Z=3 Q=. _ERROR_=1 _N_=1 Mathematical operations could not be performed at the following places. The results of the operations have been set to missing values. NOTE: Missing values were generated as a result of performing an operation on missing NOTE: SAS went to a new line when INPUT statement reached past the end of a line. NOTE: LOST CARD. 10 Intermediate SAS
3. Almost always use system options options compress =yes nocenter; /* mostly use */ options ps=9999 ls=200;
Randy s SAS hints, updated Feb 6, 2014 1. Always begin your programs with internal documentation. * ***************** * Program =test1, Randy Ellis, first version: March 8, 2013 ***************; 2. Don
More information2. Don t forget semicolons and RUN statements The two most common programming errors.
Randy s SAS hints March 7, 2013 1. Always begin your programs with internal documentation. * ***************** * Program =test1, Randy Ellis, March 8, 2013 ***************; 2. Don t forget semicolons and
More informationSAS Training Spring 2006
SAS Training Spring 2006 Coxe/Maner/Aiken Introduction to SAS: This is what SAS looks like when you first open it: There is a Log window on top; this will let you know what SAS is doing and if SAS encountered
More informationIntermediate SAS: Statistics
Intermediate SAS: Statistics OIT TSS 293-4444 oithelp@mail.wvu.edu oit.wvu.edu/training/classmat/sas/ Table of Contents Procedures... 2 Two-sample t-test:... 2 Paired differences t-test:... 2 Chi Square
More informationChapter 2: Getting Data Into SAS
Chapter 2: Getting Data Into SAS Data stored in many different forms/formats. Four categories of ways to read in data. 1. Entering data directly through keyboard 2. Creating SAS data sets from raw data
More informationLab #1: Introduction to Basic SAS Operations
Lab #1: Introduction to Basic SAS Operations Getting Started: OVERVIEW OF SAS (access lab pages at http://www.stat.lsu.edu/exstlab/) There are several ways to open the SAS program. You may have a SAS icon
More informationIntroductory Guide to SAS:
Introductory Guide to SAS: For UVM Statistics Students By Richard Single Contents 1 Introduction and Preliminaries 2 2 Reading in Data: The DATA Step 2 2.1 The DATA Statement............................................
More informationBase and Advance SAS
Base and Advance SAS BASE SAS INTRODUCTION An Overview of the SAS System SAS Tasks Output produced by the SAS System SAS Tools (SAS Program - Data step and Proc step) A sample SAS program Exploring SAS
More informationEpidemiology Principles of Biostatistics Chapter 3. Introduction to SAS. John Koval
Epidemiology 9509 Principles of Biostatistics Chapter 3 John Koval Department of Epidemiology and Biostatistics University of Western Ontario What we will do today We will learn to use use SAS to 1. read
More information22S:166. Checking Values of Numeric Variables
22S:1 Computing in Statistics Lecture 24 Nov. 2, 2016 1 Checking Values of Numeric Variables range checks when you know what the range of possible values is for a given quantitative variable internal consistency
More informationLecture 1 Getting Started with SAS
SAS for Data Management, Analysis, and Reporting Lecture 1 Getting Started with SAS Portions reproduced with permission of SAS Institute Inc., Cary, NC, USA Goals of the course To provide skills required
More informationINTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS
TO SAS NEED FOR SAS WHO USES SAS WHAT IS SAS? OVERVIEW OF BASE SAS SOFTWARE DATA MANAGEMENT FACILITY STRUCTURE OF SAS DATASET SAS PROGRAM PROGRAMMING LANGUAGE ELEMENTS OF THE SAS LANGUAGE RULES FOR SAS
More informationSAS 101. Based on Learning SAS by Example: A Programmer s Guide Chapter 21, 22, & 23. By Tasha Chapman, Oregon Health Authority
SAS 101 Based on Learning SAS by Example: A Programmer s Guide Chapter 21, 22, & 23 By Tasha Chapman, Oregon Health Authority Topics covered All the leftovers! Infile options Missover LRECL=/Pad/Truncover
More informationA Step by Step Guide to Learning SAS
A Step by Step Guide to Learning SAS 1 Objective Familiarize yourselves with the SAS programming environment and language. Learn how to create and manipulate data sets in SAS and how to use existing data
More informationSAS PROGRAMMING AND APPLICATIONS (STAT 5110/6110): FALL 2015 Module 2
SAS PROGRAMMING AND APPLICATIONS (STAT 5110/6110): FALL 2015 Department of MathemaGcs and StaGsGcs Phone: 4-3620 Office: Parker 364- A E- mail: carpedm@auburn.edu Web: hup://www.auburn.edu/~carpedm/stat6110
More informationChapter 1 The DATA Step
Chapter 1 The DATA Step 1.1 Structure of SAS Programs...1-3 1.2 SAS Data Sets... 1-12 1.3 Creating a Permanent SAS Data Set... 1-18 1.4 Writing a SAS DATA Step... 1-24 1.5 Creating a DATA Step View...
More informationIntroductory SAS example
Introductory SAS example STAT:5201 1 Introduction SAS is a command-driven statistical package; you enter statements in SAS s language, submit them to SAS, and get output. A fairly friendly user interface
More informationChapter 6: Modifying and Combining Data Sets
Chapter 6: Modifying and Combining Data Sets The SET statement is a powerful statement in the DATA step. Its main use is to read in a previously created SAS data set which can be modified and saved as
More informationSTAT 7000: Experimental Statistics I
STAT 7000: Experimental Statistics I 2. A Short SAS Tutorial Peng Zeng Department of Mathematics and Statistics Auburn University Fall 2009 Peng Zeng (Auburn University) STAT 7000 Lecture Notes Fall 2009
More informationOverview of Data Management Tasks (command file=datamgt.sas)
Overview of Data Management Tasks (command file=datamgt.sas) Create the March data set: To create the March data set, you can read it from the MARCH.DAT raw data file, using a data step, as shown below.
More informationST Lab 1 - The basics of SAS
ST 512 - Lab 1 - The basics of SAS What is SAS? SAS is a programming language based in C. For the most part SAS works in procedures called proc s. For instance, to do a correlation analysis there is proc
More informationIntroduction to DATA Step Programming: SAS Basics II. Susan J. Slaughter, Avocet Solutions
Introduction to DATA Step Programming: SAS Basics II Susan J. Slaughter, Avocet Solutions SAS Essentials Section for people new to SAS Core presentations 1. How SAS Thinks 2. Introduction to DATA Step
More informationGetting Your Data into SAS The Basics. Math 3210 Dr. Zeng Department of Mathematics California State University, Bakersfield
Getting Your Data into SAS The Basics Math 3210 Dr. Zeng Department of Mathematics California State University, Bakersfield Outline Getting data into SAS -Entering data directly into SAS -Creating SAS
More informationIntroduction to SAS. Cristina Murray-Krezan Research Assistant Professor of Internal Medicine Biostatistician, CTSC
Introduction to SAS Cristina Murray-Krezan Research Assistant Professor of Internal Medicine Biostatistician, CTSC cmurray-krezan@salud.unm.edu 20 August 2018 What is SAS? Statistical Analysis System,
More informationSAS CURRICULUM. BASE SAS Introduction
SAS CURRICULUM BASE SAS Introduction Data Warehousing Concepts What is a Data Warehouse? What is a Data Mart? What is the difference between Relational Databases and the Data in Data Warehouse (OLTP versus
More informationssh tap sas913 sas
Fall 2010, STAT 430 SAS Examples SAS9 ===================== ssh abc@glue.umd.edu tap sas913 sas https://www.statlab.umd.edu/sasdoc/sashtml/onldoc.htm a. Reading external files using INFILE and INPUT (Ch
More informationStat 302 Statistical Software and Its Applications SAS: Data I/O
Stat 302 Statistical Software and Its Applications SAS: Data I/O Yen-Chi Chen Department of Statistics, University of Washington Autumn 2016 1 / 33 Getting Data Files Get the following data sets from the
More informationINTRODUCTION SAS Prepared by A. B. Billings West Virginia University May 1999 (updated August 2006)
INTRODUCTION To SAS Prepared by A. B. Billings West Virginia University May 1999 (updated August 2006) 1 Getting Started with SAS SAS stands for Statistical Analysis System. SAS is a computer software
More informationERROR: ERROR: ERROR:
ERROR: ERROR: ERROR: Formatting Variables: Back and forth between character and numeric Why should you care? DATA name1; SET name; if var = Three then delete; if var = 3 the en delete; if var = 3 then
More informationBiostatistics 600 SAS Lab Supplement 1 Fall 2012
Biostatistics 600 SAS Lab Supplement 1 Fall 2012 p 2. How to Enter Data in the Program Editor Window: Instream Data p 5. How to Create a SAS Data Set from Raw Data Files p 16. Using Dates in SAS 1 How
More informationStat 302 Statistical Software and Its Applications SAS: Data I/O & Descriptive Statistics
Stat 302 Statistical Software and Its Applications SAS: Data I/O & Descriptive Statistics Fritz Scholz Department of Statistics, University of Washington Winter Quarter 2015 February 19, 2015 2 Getting
More informationIntroduction to DATA Step Programming SAS Basics II. Susan J. Slaughter, Avocet Solutions
Introduction to DATA Step Programming SAS Basics II Susan J. Slaughter, Avocet Solutions SAS Essentials Section for people new to SAS Core presentations 1. How SAS Thinks 2. Introduction to DATA Step Programming
More informationCreate your first workbook
Create your first workbook You've been asked to enter data in Excel, but you've never worked with Excel. Where do you begin? Or perhaps you have worked in Excel a time or two, but you still wonder how
More informationFormats, Informats and How to Program with Them Ian Whitlock, Westat, Rockville, MD
Formats, Informats and How to Program with Them Ian Whitlock, Westat, Rockville, MD Abstract Formats tell how to display stored data and informats how to read them. In other words, they allow the separation
More informationGetting Up to Speed with PROC REPORT Kimberly LeBouton, K.J.L. Computing, Rossmoor, CA
SESUG 2012 Paper HW-01 Getting Up to Speed with PROC REPORT Kimberly LeBouton, K.J.L. Computing, Rossmoor, CA ABSTRACT Learning the basics of PROC REPORT can help the new SAS user avoid hours of headaches.
More informationAn Introduction to SAS University Edition
An Introduction to SAS University Edition Ron Cody From An Introduction to SAS University Edition. Full book available for purchase here. Contents List of Programs... xi About This Book... xvii About the
More informationCMU MSP : SAS FORMATs and INFORMATs Howard Seltman Nov. 7+12, 2018
CMU MSP 36-601: SAS FORMATs and INFORMATs Howard Seltman Nov. 7+12, 2018 1) Formats and informats flexibly re-represent data in a data set on input or output. Common uses include reading and writing dates,
More informationCustomizing Your SAS Session
13 CHAPTER 2 Customizing Your SAS Session Introduction 13 Specifying System Options in the SAS Command 14 Configuration Files 15 Creating a User Configuration File 15 Specifying a User Configuration File
More informationLeave Your Bad Code Behind: 50 Ways to Make Your SAS Code Execute More Efficiently.
Leave Your Bad Code Behind: 50 Ways to Make Your SAS Code Execute More Efficiently. William E Benjamin Jr Owl Computer Consultancy, LLC 2012 Topic Groups Processing more than one file in each DATA step
More informationSTAT:5400 Computing in Statistics
STAT:5400 Computing in Statistics Introduction to SAS Lecture 18 Oct 12, 2015 Kate Cowles 374 SH, 335-0727 kate-cowles@uiowaedu SAS SAS is the statistical software package most commonly used in business,
More informationPHPM 672/677 Lab #2: Variables & Conditionals Due date: Submit by 11:59pm Monday 2/5 with Assignment 2
PHPM 672/677 Lab #2: Variables & Conditionals Due date: Submit by 11:59pm Monday 2/5 with Assignment 2 Overview Most assignments will have a companion lab to help you learn the task and should cover similar
More informationPaper S Data Presentation 101: An Analyst s Perspective
Paper S1-12-2013 Data Presentation 101: An Analyst s Perspective Deanna Chyn, University of Michigan, Ann Arbor, MI Anca Tilea, University of Michigan, Ann Arbor, MI ABSTRACT You are done with the tedious
More informationPROC MEANS for Disaggregating Statistics in SAS : One Input Data Set and One Output Data Set with Everything You Need
ABSTRACT Paper PO 133 PROC MEANS for Disaggregating Statistics in SAS : One Input Data Set and One Output Data Set with Everything You Need Imelda C. Go, South Carolina Department of Education, Columbia,
More informationTIPS FROM THE TRENCHES
TIPS FROM THE TRENCHES Christopher Bost MDRC SAS Users Group October 1, 2008 Recent user questions 2 How can I print long character values? How can I EXPORT formatted values to Excel? How can I check for
More informationSAS Programs SAS Lecture 4 Procedures. Aidan McDermott, April 18, Outline. Internal SAS formats. SAS Formats
SAS Programs SAS Lecture 4 Procedures Aidan McDermott, April 18, 2006 A SAS program is in an imperative language consisting of statements. Each statement ends in a semi-colon. Programs consist of (at least)
More informationApril 4, SAS General Introduction
PP 105 Spring 01-02 April 4, 2002 SAS General Introduction TA: Kanda Naknoi kanda@stanford.edu Stanford University provides UNIX computing resources for its academic community on the Leland Systems, which
More informationPosters. Workarounds for SASWare Ballot Items Jack Hamilton, First Health, West Sacramento, California USA. Paper
Paper 223-25 Workarounds for SASWare Ballot Items Jack Hamilton, First Health, West Sacramento, California USA ABSTRACT As part of its effort to insure that SAS Software is useful to its users, SAS Institute
More informationAccessing Data and Creating Data Structures. SAS Global Certification Webinar Series
Accessing Data and Creating Data Structures SAS Global Certification Webinar Series Accessing Data and Creating Data Structures Becky Gray Certification Exam Developer SAS Global Certification Michele
More informationBiology 345: Biometry Fall 2005 SONOMA STATE UNIVERSITY Lab Exercise 2 Working with data in Excel and exporting to JMP Introduction
Biology 345: Biometry Fall 2005 SONOMA STATE UNIVERSITY Lab Exercise 2 Working with data in Excel and exporting to JMP Introduction In this exercise, we will learn how to reorganize and reformat a data
More informationSAS Online Training: Course contents: Agenda:
SAS Online Training: Course contents: Agenda: (1) Base SAS (6) Clinical SAS Online Training with Real time Projects (2) Advance SAS (7) Financial SAS Training Real time Projects (3) SQL (8) CV preparation
More informationWriting Programs in SAS Data I/O in SAS
Writing Programs in SAS Data I/O in SAS Statistics 135 Autumn 2005 Copyright c 2005 by Mark E. Irwin Writing SAS Programs Your SAS programs can be written in any text editor, though you will often want
More informationOpen Problem for SUAVe User Group Meeting, November 26, 2013 (UVic)
Open Problem for SUAVe User Group Meeting, November 26, 2013 (UVic) Background The data in a SAS dataset is organized into variables and observations, which equate to rows and columns. While the order
More informationIntroduction to SAS. I. Understanding the basics In this section, we introduce a few basic but very helpful commands.
Center for Teaching, Research and Learning Research Support Group American University, Washington, D.C. Hurst Hall 203 rsg@american.edu (202) 885-3862 Introduction to SAS Workshop Objective This workshop
More informationDSCI 325: Handout 2 Getting Data into SAS Spring 2017
DSCI 325: Handout 2 Getting Data into SAS Spring 2017 Data sets come in many different formats. In some situations, data sets are stored on paper (e.g., surveys) and other times data are stored in huge
More informationCMU MSP : SAS FORMATs and INFORMATs Howard Seltman October 15, 2017
CMU MSP 36-601: SAS FORMATs and INFORMATs Howard Seltman October 15, 2017 1) Informats are programs that convert ASCII (Unicode) text to binary. Formats are programs that convert binary to text. Both come
More informationAN INTRODUCTION TO MACRO VARIABLES AND MACRO PROGRAMS Mike Zdeb, School of Public Health
AN INTRODUCTION TO MACRO VARIABLES AND MACRO PROGRAMS Mike Zdeb, University@Albany School of Public Health INTRODUCTION There are a number of SAS tools that you may never have to use. Why? The main reason
More informationSAS 101. Based on Learning SAS by Example: A Programmer s Guide Chapters 9, 11 & 12. By Tasha Chapman, Oregon Health Authority
SAS 101 Based on Learning SAS by Example: A Programmer s Guide Chapters 9, 11 & 12 By Tasha Chapman, Oregon Health Authority Topics covered SAS dates Date functions Numeric functions Character functions
More informationTIPS AND TRICKS: IMPROVE EFFICIENCY TO YOUR SAS PROGRAMMING
TIPS AND TRICKS: IMPROVE EFFICIENCY TO YOUR SAS PROGRAMMING Guillaume Colley, Lead Data Analyst, BCCFE Page 1 Contents Customized SAS Session Run system options as SAS starts Labels management Shortcut
More informationChristopher Toppe, Ph.D. Computer Sciences Corporation
An Introduction to PROC TABULATE: A Hands-On Workshop Christopher Toppe, Ph.D. Computer Sciences Corporation Abstract The Tabulate procedure is, along with PROC REPORT, one of the most powerful and difficult
More informationCreate a SAS Program to create the following files from the PREC2 sas data set created in LAB2.
Topics: Data step Subsetting Concatenation and Merging Reference: Little SAS Book - Chapter 5, Section 3.6 and 2.2 Online documentation Exercise I LAB EXERCISE The following is a lab exercise to give you
More informationReading data in SAS and Descriptive Statistics
P8130 Recitation 1: Reading data in SAS and Descriptive Statistics Zilan Chai Sep. 18 th /20 th 2017 Outline Intro to SAS (windows, basic rules) Getting Data into SAS Descriptive Statistics SAS Windows
More informationMastering the Basics: Preventing Problems by Understanding How SAS Works. Imelda C. Go, South Carolina Department of Education, Columbia, SC
SESUG 2012 ABSTRACT Paper PO 06 Mastering the Basics: Preventing Problems by Understanding How SAS Works Imelda C. Go, South Carolina Department of Education, Columbia, SC There are times when SAS programmers
More informationBiostatistics & SAS programming. Kevin Zhang
Biostatistics & SAS programming Kevin Zhang January 26, 2017 Biostat 1 Instructor Instructor: Dong Zhang (Kevin) Office: Ben Franklin Hall 227 Phone: 570-389-4556 Email: dzhang(at)bloomu.edu Class web:
More informationproc print data=account; <insert statement here> run;
Statistics 6250 Name: Fall 2012 (print: first last ) Prof. Fan NetID #: Midterm Three Instructions: This is an in-class and open book midterm. You must write your answers on the provide spaces. Give concise
More informationSAS seminar. The little SAS book Chapters 3 & 4. April 15, Åsa Klint. By LD Delwiche and SJ Slaughter. 3.1 Creating and Redefining variables
SAS seminar April 15, 2003 Åsa Klint The little SAS book Chapters 3 & 4 By LD Delwiche and SJ Slaughter Data step - read and modify data - create a new dataset - performs actions on rows Proc step - use
More information22S:172. Duplicates. may need to check for either duplicate ID codes or duplicate observations duplicate observations should just be eliminated
22S:172 1 2 Duplicates Data Cleaning involving duplicate IDs and duplicate records may need to check for either duplicate ID codes or duplicate observations duplicate observations should just be eliminated
More informationIntroduction to Stata Getting Data into Stata. 1. Enter Data: Create a New Data Set in Stata...
Introduction to Stata 2016-17 02. Getting Data into Stata 1. Enter Data: Create a New Data Set in Stata.... 2. Enter Data: How to Import an Excel Data Set.... 3. Import a Stata Data Set Directly from the
More informationSAS Macro Language: Reference
SAS Macro Language: Reference INTRODUCTION Getting Started with the Macro Facility This is the macro facility language reference for the SAS System. It is a reference for the SAS macro language processor
More informationMATH 707-ST: Introduction to Statistical Computing with SAS and R. MID-TERM EXAM (Writing part) Fall, (Time allowed: TWO Hours)
MATH 707-ST: Introduction to Statistical Computing with SAS and R MID-TERM EXAM (Writing part) Fall, 2013 (Time allowed: TWO Hours) Highlight your answer clearly for each question. There is only one correct
More informationLevel I: Getting comfortable with my data in SAS. Descriptive Statistics
Level I: Getting comfortable with my data in SAS. Descriptive Statistics Quick Review of reading Data into SAS Preparing Data 1. Variable names in the first row make sure they are appropriate for the statistical
More information1 Downloading files and accessing SAS. 2 Sorting, scatterplots, correlation and regression
Statistical Methods and Computing, 22S:30/105 Instructor: Cowles Lab 2 Feb. 6, 2015 1 Downloading files and accessing SAS. We will be using the billion.dat dataset again today, as well as the OECD dataset
More informationINTRODUCTION to. Program in Statistics and Methodology (PRISM) Daniel Blake & Benjamin Jones January 15, 2010
INTRODUCTION to Program in Statistics and Methodology (PRISM) Daniel Blake & Benjamin Jones January 15, 2010 While we are waiting Everyone who wishes to work along with the presentation should log onto
More informationLab #3: Probability, Simulations, Distributions:
Lab #3: Probability, Simulations, Distributions: A. Objectives: 1. Reading from an external file 2. Create contingency table 3. Simulate a probability distribution 4. The Uniform Distribution Reading from
More informationEcon Stata Tutorial I: Reading, Organizing and Describing Data. Sanjaya DeSilva
Econ 329 - Stata Tutorial I: Reading, Organizing and Describing Data Sanjaya DeSilva September 8, 2008 1 Basics When you open Stata, you will see four windows. 1. The Results window list all the commands
More informationThe TIMEPLOT Procedure
1247 CHAPTER 38 The TIMEPLOT Procedure Overview 1247 Procedure Syntax 1249 PROC TIMEPLOT Statement 1250 BY Statement 1250 CLASS Statement 1251 ID Statement 1252 PLOT Statement 1252 Results 1257 Data Considerations
More information1 Files to download. 3 Macro to list the highest and lowest N data values. 2 Reading in the example data file
1 2 22S:172 Lab session 10 Macros for data cleaning July 17, 2003 GENDER VISIT HR SBP DBP DX AE = "Gender" = "Visit Date" = "Heart Rate" = "Systolic Blood Pressure" = "Diastolic Blood Pressure" = "Diagnosis
More informationEXAMPLE 2: INTRODUCTION TO SAS AND SOME NOTES ON HOUSEKEEPING PART II - MATCHING DATA FROM RESPONDENTS AT 2 WAVES INTO WIDE FORMAT
EXAMPLE 2: PART I - INTRODUCTION TO SAS AND SOME NOTES ON HOUSEKEEPING PART II - MATCHING DATA FROM RESPONDENTS AT 2 WAVES INTO WIDE FORMAT USING THESE WORKSHEETS For each of the worksheets you have a
More informationThe editor window is where we write our SAS programs which we will begin doing shortly.
Introductions Overview of SAS Welcome to our SAS tutorials. This first tutorial will provide a basic overview of the SAS environment and SAS programming. We don t want you to try to follow along with this
More informationLecture 05 I/O statements Printf, Scanf Simple statements, Compound statements
Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple
More informationIntroduction to SAS Mike Zdeb ( , #61
Mike Zdeb (402-6479, msz03@albany.edu) #61 FORMAT, you can design informats for reading and interpreting non-standard data, and you can design formats for displaying data in non-standard ways....example
More informationA SAS Macro for Producing Benchmarks for Interpreting School Effect Sizes
A SAS Macro for Producing Benchmarks for Interpreting School Effect Sizes Brian E. Lawton Curriculum Research & Development Group University of Hawaii at Manoa Honolulu, HI December 2012 Copyright 2012
More informationIntroduction to MATLAB
Introduction to MATLAB Introduction: MATLAB is a powerful high level scripting language that is optimized for mathematical analysis, simulation, and visualization. You can interactively solve problems
More informationExcel R Tips. is used for multiplication. + is used for addition. is used for subtraction. / is used for division
Excel R Tips EXCEL TIP 1: INPUTTING FORMULAS To input a formula in Excel, click on the cell you want to place your formula in, and begin your formula with an equals sign (=). There are several functions
More informationA Cross-national Comparison Using Stacked Data
A Cross-national Comparison Using Stacked Data Goal In this exercise, we combine household- and person-level files across countries to run a regression estimating the usual hours of the working-aged civilian
More informationASSIGNMENT #2 ( *** ANSWERS ***) 1
ASSIGNMENT #2 ( *** ANSWERS ***) 1 * problem #1 *** WHERE WILL THE PERMANENT SAS DATA SET BE WRITTEN libname x 'i:\' CREATE A PERMANENT SAS DATA SET NAMED CLINICAL USE AN INFILE STATEMENT TO TELL SAS WHERE
More informationIntroduction to the SAS System
Introduction to the SAS System The SAS Environment The SAS Environment The SAS Environment has five main windows The SAS Environment The Program Editor The SAS Environment The Log: Notes, Warnings and
More informationIntroduction to SAS Mike Zdeb ( , #1
Mike Zdeb (402-6479, msz03@albany.edu) #1 (1) INTRODUCTION Once, the acronym SAS actually did stand for Statistical Analysis System. Now, when you use the term SAS, you are referring to a collection of
More information/23/2004 TA : Jiyoon Kim. Recitation Note 1
Recitation Note 1 This is intended to walk you through using STATA in an Athena environment. The computer room of political science dept. has STATA on PC machines. But, knowing how to use it on Athena
More informationPaper # Jazz it up a Little with Formats. Brian Bee, The Knowledge Warehouse Ltd
Paper #1495-2014 Jazz it up a Little with Formats Brian Bee, The Knowledge Warehouse Ltd Abstract Formats are an often under-valued tool in the SAS toolbox. They can be used in just about all domains to
More informationPROC FORMAT Jack Shoemaker Real Decisions Corporation
140 Beginning Tutorials PROC FORMAT Jack Shoemaker Real Decisions Corporation Abstract: Although SAS stores and processes data intemally as either characters or numbers, you can control the external view
More informationDSCI 325: Handout 10 Summarizing Numerical and Categorical Data in SAS Spring 2017
DSCI 325: Handout 10 Summarizing Numerical and Categorical Data in SAS Spring 2017 USING PROC MEANS The routine PROC MEANS can be used to obtain limited summaries for numerical variables (e.g., the mean,
More informationR Basics / Course Business
R Basics / Course Business We ll be using a sample dataset in class today: CourseWeb: Course Documents " Sample Data " Week 2 Can download to your computer before class CourseWeb survey on research/stats
More informationMicrosoft Office Excel Use Excel s functions. Tutorial 2 Working With Formulas and Functions
Microsoft Office Excel 2003 Tutorial 2 Working With Formulas and Functions 1 Use Excel s functions You can easily calculate the sum of a large number of cells by using a function. A function is a predefined,
More information%MAKE_IT_COUNT: An Example Macro for Dynamic Table Programming Britney Gilbert, Juniper Tree Consulting, Porter, Oklahoma
Britney Gilbert, Juniper Tree Consulting, Porter, Oklahoma ABSTRACT Today there is more pressure on programmers to deliver summary outputs faster without sacrificing quality. By using just a few programming
More informationCopyright 2018 Maxprograms
Copyright 2018 Maxprograms Table of Contents Introduction... 1 TMXEditor... 1 Features... 1 Getting Started... 2 Editing an existing file... 2 Create New TMX File... 3 Maintenance Tasks... 4 Sorting TM
More informationCentering and Interactions: The Training Data
Centering and Interactions: The Training Data A random sample of 150 technical support workers were first given a test of their technical skill and knowledge, and then randomly assigned to one of three
More informationChapter 1: Introduction to SAS
Chapter 1: Introduction to SAS SAS programs: A sequence of statements in a particular order. Rules for SAS statements: 1. Every SAS statement ends in a semicolon!!!; 2. Upper/lower case does not matter
More informationThe REPORT Procedure CHAPTER 32
859 CHAPTER 32 The REPORT Procedure Overview 861 Types of Reports 861 A Sampling of Reports 861 Concepts 866 Laying Out a Report 866 Usage of Variables in a Report 867 Display Variables 867 Order Variables
More informationCSC 328/428 Summer Session I 2002 Data Analysis for the Experimenter FINAL EXAM
options pagesize=53 linesize=76 pageno=1 nodate; proc format; value $stcktyp "1"="Growth" "2"="Combined" "3"="Income"; data invstmnt; input stcktyp $ perform; label stkctyp="type of Stock" perform="overall
More informationThe SAS interface is shown in the following screen shot:
The SAS interface is shown in the following screen shot: There are several items of importance shown in the screen shot First there are the usual main menu items, such as File, Edit, etc I seldom use anything
More information