SAS 101. Based on Learning SAS by Example: A Programmer s Guide Chapter 21, 22, & 23. By Tasha Chapman, Oregon Health Authority

Size: px
Start display at page:

Download "SAS 101. Based on Learning SAS by Example: A Programmer s Guide Chapter 21, 22, & 23. By Tasha Chapman, Oregon Health Authority"

Transcription

1 SAS 101 Based on Learning SAS by Example: A Programmer s Guide Chapter 21, 22, & 23 By Tasha Chapman, Oregon Health Authority

2 Topics covered All the leftovers! Infile options Missover LRECL=/Pad/Truncover FirstObs=/OBS=

3 Topics covered Advanced formats and informats User created informats Reading both character and numeric data Formats within formats Saving formats Using formats as look-up tables CNTLIN and CNTLOUT datasets

4 Topics covered Transposing data PROC Transpose Other topics Saving and storing macros %Include Autocall library Stored compiled macros

5 Infile options

6 PROC Import with a twist (redux) Run PROC Import Copy the SAS log to the Program Editor PROC Import will create a DATA step with INFILE and INPUT statements in the log Delete any non-sas code Modify informats, formats, and lengths (as needed) Run the new code From Week 3 Chapters 5 & 6

7 PROC Import with a twist (redux) Infile statement options Run PROC Import Copy the SAS log to the Program Editor Delete any non-sas code Modify informats, formats, and lengths (as needed) Run the new code From Week 3 Chapters 5 & 6

8 Common INFILE options Option dsd dlm= missover lrecl= pad truncover firstobs= obs= Purpose Stands for delimiter sensitive data. Changes default delimiter from blank to comma. If two delimiters in a row, assumes missing value between. Quotes stripped from character values. Stands for delimiter. Specifies alternate delimiter(s). At the end of an input line of raw data, sets remaining values to missing if there are more variables than data values. Stands for logical record length. Specifies the record length of the raw data file (necessary if greater than the default 256 bytes). Pads the input records with blanks out the the end of the logical record length. Essentially has the effect of both PAD and MISSOVER options combined. Specifies which record number in the raw dataset is the first observation of data. Useful if raw data includes headers. Specifies the record number of the last record to read. Useful if only want to read a select number of observations.

9 MISSOVER Missing data results in shorter than expected line

10 MISSOVER MISSOVER option fills in the blanks at the end of the line with missing values.

11 Common INFILE options Option dsd dlm= missover lrecl= pad truncover firstobs= obs= Purpose Stands for delimiter sensitive data. Changes default delimiter from blank to comma. If two delimiters in a row, assumes missing value between. Quotes stripped from character values. Stands for delimiter. Specifies alternate delimiter(s). At the end of an input line of raw data, sets remaining values to missing if there are more variables than data values. Stands for logical record length. Specifies the record length of the raw data file (necessary if greater than the default 256 bytes). Pads the input records with blanks out the the end of the logical record length. Essentially has the effect of both PAD and MISSOVER options combined. Specifies which record number in the raw dataset is the first observation of data. Useful if raw data includes headers. Specifies the record number of the last record to read. Useful if only want to read a select number of observations.

12 FIRSTOBS=

13 FIRSTOBS= First row contains header information

14 FIRSTOBS= FIRSTOBS=2 option starts reading the raw data file on the second row.

15 Common INFILE options Option dsd dlm= missover lrecl= pad truncover firstobs= obs= Purpose Stands for delimiter sensitive data. Changes default delimiter from blank to comma. If two delimiters in a row, assumes missing value between. Quotes stripped from character values. Stands for delimiter. Specifies alternate delimiter(s). At the end of an input line of raw data, sets remaining values to missing if there are more variables than data values. Stands for logical record length. Specifies the record length of the raw data file (necessary if greater than the default 256 bytes). Pads the input records with blanks out the the end of the logical record length. Essentially has the effect of both PAD and MISSOVER options combined. Specifies which record number in the raw dataset is the first observation of data. Useful if raw data includes headers. Specifies the record number of the last record to read. Useful if only want to read a select number of observations.

16 Advanced formats and informats

17 PROC Format (redux) value $gender Input value Output value Value statement begins new format Can create more than one format per PROC Format $gender is the name of the new format Format name begins with a $ to indicate that the format is to be applied to Character data From Week 3 Chapters 5 & 6

18 What are informats? (redux) Informats are instructions that tell SAS how to read a data value Can be as simple as w.d 3.1 tells SAS to read 123 as 12.3 $3. tells SAS to read 123 as 123 and store it as character data Excellent for reading dates, dollars, and percents MMDDYY8. tells SAS to read 12/26/07 and store it as (a SAS date that can be used for calculations, etc.) From Week 3 Chapters 5 & 6

19 Creating informats invalue score Input value Output value Invalue statement creates informats Dollar sign $ indicates format will be creating character variables (i.e. output value will be character) Absence of dollar sign indicates format will be creating numeric variables (as in this example)

20 Creating informats Survey scale entered as character values (SA = Strongly Agree, A = Agree, etc.) Want to convert to numeric Likert-type scale

21 Creating informats Use PROC Format to create the informat score Apply the informat while reading in the raw data

22 Creating informats UPCASE option Converts all input strings to uppercase before they are compared to ranges JUST option Left justifies all input strings before they are compared to ranges Useful options as raw data may be messy (mixed case, leading blanks, etc.)

23 Creating informats Dataset of patient temperature readings Normal temperature coded as N Actual temperature entered if not normal Both character and numeric data in same field

24 Creating informats Use PROC Format to create the informat tempfmt Numeric temperatures within valid range will be read as written. N will be converted to Any other values (including numeric temps outside valid range) will be converted to missing.

25 Formats within formats Formats and informats can be nested within each other Useful for applying multiple types of formats (e.g. picture and value formats) to the same variable depending on the data value

26 Formats within formats Phone directory dataset Some provided full phone numbers Want to show as (999) Some provided extensions Want to show as x9999 Some have no phone number Want to show as Unlisted

27 Formats within formats (503) x1793 Applies format based on data value

28 Saving and storing formats PROC Format saves user-created formats to a catalog Usually these catalogs are in the WORK library, and are deleted at the end of each SAS Session However, formats can be easily saved and stored to other permanent libraries

29 Saving and storing formats Save a format to a permanent library using a library= option This will create a formats catalog (called formats by default) in the mylib folder

30 Saving and storing formats To use the saved formats in another program, use the fmtsearch= option to add that catalog to the list of available formats

31 CNTLIN/CNTLOUT Can create a format from a dataset using the CNTLIN= option in PROC Format Can create a dataset from a format using the CNTLOUT= option in PROC Format

32 CNTLIN/CNTLOUT Have a dataset of ICD9 codes and descriptions Want to convert this to a SAS format

33 CNTLIN/CNTLOUT The input dataset has to have specific variables: FMTNAME name of the format START the single value to be formatted (or start value if the beginning of a range of values) END (optional) the end value of a range of values to be formatted LABEL the formatted value TYPE (optional) type of format, C for character, N for numeric

34 CNTLIN/CNTLOUT Original dataset Ready to be made into a format

35 CNTLIN/CNTLOUT Use PROC Format to convert the dataset to a format

36 CNTLIN/CNTLOUT Use PROC Format to convert a format to a dataset

37 Transposing data

38 Transposing data

39 Transposing data Transposing is converting variables to observations and vice versa Multiple ways of restructuring and transposing data PROC Transpose DATA step Arrays and DO Loops

40 Transposing data basic example Output (transposed) dataset Seven variables Two observations Input (original) dataset Two variables Seven observations

41 Transposing data basic example data= Input (original) dataset out= Output (transposed) dataset

42 Transposing data basic example Name of transposed variables stored in _NAME_ column

43 Transposing data basic example New variables generically named COL1, COL2, etc.

44 VAR statement The var statement specifies which variables should be transposed If omitted, by default PROC Transpose will only transpose numeric variables

45 ID statement The ID statement specifies which variables should be used to name the new columns If the value is not a valid variable name (e.g., starts with a number), SAS will convert it to a valid name (e.g., leading underscore)

46 ID statement The variable names can be modified with the prefix=, delimiter=, or suffix= options

47 Transposing data BY groups Two temperatures (HighTemp and LowTemp) Three cities (Eugene, Portland, and Salem)

48 BY statement Can specify more than one BY group variable Data must be sorted by BY group variable(s)

49 BY statement DayOf Week City HighTemp LowTemp 1 Eugene Eugene Eugene Eugene Eugene Eugene Eugene Portland Portland Portland Portland Portland City _NAME_ Day1 Day2 Day3 Day4 Day5 Day6 Day7 Eugene HighTemp Eugene LowTemp Portland HighTemp Portland LowTemp Salem HighTemp Salem LowTemp Portland Portland Salem Salem Salem Salem Salem Salem Salem 68 46

50 NAME= option Use the name= option to name the variable containing the name of the transposed variable (_NAME_ column)

51 Saving and storing macros

52 Saving and storing macros Need to store and share macro code Multiple ways to save and store macros for future use %Include Autocall facility Stored compiled macro facility

53 Saving and storing macros Which method to choose depends on your needs and operating environment SAS recommends: Don t store macros while still in development If you are running production-level jobs using namestyle macros, consider stored compiled macros If you are letting a group of users share macros, consider the autocall facility

54 LIBNAME trick (redux) Save your commonly used and/or passworded LIBNAME statements in a text file (using Notepad) Use a %include statement to reference the text file at the beginning of every SAS program SAS will include the code in the text file as if it were part of your program. From Week 2 Chapters 3 & 4

55 %Include Save your macro definitions in a text file Use %include to reference the file at the start of every program

56 %Include Advantages: Easy and straightforward approach Excellent first step towards starting a macro library Disadvantages: The macro definition is compiled every time the %include is executed (inefficient) If efficiency is an issue, each file should contain only one macro (which would result in multiple files to include) Requires you to know where the physical text files are stored

57 Autocall facility An autocall library is a directory containing individual files Similar in concept to %include, but files stored as SAS files Each file contains one macro definition The name of the file must be the same as the macro name An autocall library can also be a SAS catalog

58 Autocall facility Save the SAS code for your macro using the macro name as the program file name To avoid confusion, this folder should have nothing but autocall macros

59 Autocall facility To use the macro later Reference the folder storing the autocall macros with a FILEREF (created with a filename statement) Not a libref!

60 Autocall facility mautosource option turns on the autocall macro facility mautolocdisplay option (optional) displays the location of the source code in the log when the macro is called sasautos= option tells SAS where the autocall macros are stored

61 Autocall facility Advantages: Macros stored as SAS code can use enhanced editor to modify them User-defined macros stored in a standard location No need to remember multiple file names when calling macros Macro code only compiled the first time it is used in a session (efficient) Easy to share

62 Autocall facility Disadvantages: Because macro code only compiled once per session, this can be difficult during editing phase

63 Stored compiled macros Macros are always compiled before they are executed Compiled macros are stored in a catalog called SASMACR In a typical session, this catalog is stored in the WORK library However, this catalog can be stored in a more permanent library for future use

64 Stored compiled macros Create a library to store the SASMACR catalog

65 Stored compiled macros mstored option turns the stored compiled macro facility on sasmstore= option identifies the library where the SASMACR catalog will be stored

66 Stored compiled macros Run the macro you want to store store option tells SAS to store this macro source option (optional) stores the source code with the compiled code des= option (optional) assigns a descriptive title for the macro entry in the SAS catalog

67 Stored compiled macros To use the macro later mstored option turns the stored compiled macro facility on sasmstore= option identifies the library where the SASMACR catalog is stored

68 Stored compiled macros SASMACR catalog available to view in the Explorer Window Description stored as a file property (Right-click Properties)

69 Stored compiled macros If the source option was used during macro storage, the source code can be retrieved using %copy (Code will be printed to log)

70 Stored compiled macros Advantages: Macro programs only compiled once Compile and store is faster Can store more than one macro per catalog Keeping track of macros is easy Source code does not have to be stored with SASMACR catalog But for maintenance purposes, it is recommended

71 Stored compiled macros Disadvantages: Cannot recreate source statements from a compiled macro Cannot be moved directly to other operating systems Must be saved and recompiled under new OS at any new location May need to be recompiled for new releases of SAS

72 Saving and storing macros If macros are stored in multiple locations, SAS will search for macro definitions in this order: WORK.SASMACR catalog Stored compiled macros Autocall macros

73 Additional Reading Missover, Truncover, and Pad, Oh My!! or Making Sense of the Infile and Input Statements Yes We Can Save SAS Formats Learn the Basics of Proc Transpose Turning the Data Around: Proc Transpose and Alternative Approaches Use of a Macro to Revise Data Creating a Stored Macro Facility in Ten Minutes Ways to Store Macro Source Codes and How to Retrieve Them Building and Using Macro Libraries

74 You Did It! That s all, folks!

Chapter 2: Getting Data Into SAS

Chapter 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 information

Storing and Reusing Macros

Storing and Reusing Macros 101 CHAPTER 9 Storing and Reusing Macros Introduction 101 Saving Macros in an Autocall Library 102 Using Directories as Autocall Libraries 102 Using SAS Catalogs as Autocall Libraries 103 Calling an Autocall

More information

DSCI 325: Handout 2 Getting Data into SAS Spring 2017

DSCI 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 information

Using an ICPSR set-up file to create a SAS dataset

Using an ICPSR set-up file to create a SAS dataset Using an ICPSR set-up file to create a SAS dataset Name library and raw data files. From the Start menu, launch SAS, and in the Editor program, write the codes to create and name a folder in the SAS permanent

More information

SAS PROGRAMMING AND APPLICATIONS (STAT 5110/6110): FALL 2015 Module 2

SAS 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 information

INTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS

INTRODUCTION 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 information

Stat 302 Statistical Software and Its Applications SAS: Data I/O

Stat 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 information

Other Data Sources SAS can read data from a variety of sources:

Other Data Sources SAS can read data from a variety of sources: Other Data Sources SAS can read data from a variety of sources: Plain text files, including delimited and fixed-column files Spreadsheets, such as Excel Databases XML Others Text Files Text files of various

More information

Stat 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 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 information

Base and Advance SAS

Base 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 information

New Macro Features Added in SAS 9.3 and SAS 9.4

New Macro Features Added in SAS 9.3 and SAS 9.4 SAS1575-2015 New Macro Features Added in SAS 9.3 and SAS 9.4 Richard D. Langston, SAS Institute Inc. ABSTRACT This paper describes the new features added to the macro facility in SAS 9.3 and SAS 9.4. New

More information

Reading data in SAS and Descriptive Statistics

Reading 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 information

Introduction to SAS Mike Zdeb ( , #61

Introduction 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 information

FSEDIT Procedure Windows

FSEDIT Procedure Windows 25 CHAPTER 4 FSEDIT Procedure Windows Overview 26 Viewing and Editing Observations 26 How the Control Level Affects Editing 27 Scrolling 28 Adding Observations 28 Entering and Editing Variable Values 28

More information

16. Reading raw data in fixed fields. GIORGIO RUSSOLILLO - Cours de prépara)on à la cer)fica)on SAS «Base Programming» 364

16. Reading raw data in fixed fields. GIORGIO RUSSOLILLO - Cours de prépara)on à la cer)fica)on SAS «Base Programming» 364 16. Reading raw data in fixed fields 364 Reading raw Dataset: three solu)ons You can mix all of them! Data that SAS cannot read without further informa)on 365 Reading standard data with column input: review

More information

The Programmer's Solution to the Import/Export Wizard

The Programmer's Solution to the Import/Export Wizard The Programmer's Solution to the Import/Export Wizard Lora D. Delwiche, University of California, Davis, CA Susan J. Slaughter, SAS Consultant, Davis, CA Abstract Do you like what the Import/Export Wizard

More information

Using Dynamic Data Exchange

Using Dynamic Data Exchange 145 CHAPTER 8 Using Dynamic Data Exchange Overview of Dynamic Data Exchange 145 DDE Syntax within SAS 145 Referencing the DDE External File 146 Determining the DDE Triplet 146 Controlling Another Application

More information

Objectives Reading SAS Data Sets and Creating Variables Reading a SAS Data Set Reading a SAS Data Set onboard ia.dfwlax FirstClass Economy

Objectives Reading SAS Data Sets and Creating Variables Reading a SAS Data Set Reading a SAS Data Set onboard ia.dfwlax FirstClass Economy Reading SAS Data Sets and Creating Variables Objectives Create a SAS data set using another SAS data set as input. Create SAS variables. Use operators and SAS functions to manipulate data values. Control

More information

Accessing 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 SAS Global Certification Webinar Series Accessing Data and Creating Data Structures Becky Gray Certification Exam Developer SAS Global Certification Michele

More information

CMU MSP : SAS FORMATs and INFORMATs Howard Seltman Nov. 7+12, 2018

CMU 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 information

The INPUT Statement: Where

The INPUT Statement: Where The INPUT Statement: Where It's @ Ronald Cody, Ed.D. Robert Wood Johnson Medical School Introduction One of the most powerful features of SAS software is the ability to read data in almost any form. For

More information

CMU MSP : SAS FORMATs and INFORMATs Howard Seltman October 15, 2017

CMU 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 information

Formats, 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 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 information

Functions vs. Macros: A Comparison and Summary

Functions vs. Macros: A Comparison and Summary Functions vs. Macros: A Comparison and Summary Mahipal Vanam Phaneendhar Vanam Srinivas Vanam Percept Pharma Services, Bridgewater, NJ ABSTRACT SAS is rich in various built-in functions, and predefined

More information

using and Understanding Formats

using and Understanding Formats using and Understanding SAS@ Formats Howard Levine, DynaMark, Inc. Oblectives The purpose of this paper is to enable you to use SAS formats to perform the following tasks more effectively: Improving the

More information

Introduction 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 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 information

Utilizing the Stored Compiled Macro Facility in a Multi-user Clinical Trial Setting

Utilizing the Stored Compiled Macro Facility in a Multi-user Clinical Trial Setting Paper AD05 Utilizing the Stored Compiled Macro Facility in a Multi-user Clinical Trial Setting Mirjana Stojanovic, Duke University Medical Center, Durham, NC Dorothy Watson, Duke University Medical Center,

More information

Chapter 6: Modifying and Combining Data Sets

Chapter 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 information

Merge Processing and Alternate Table Lookup Techniques Prepared by

Merge Processing and Alternate Table Lookup Techniques Prepared by Merge Processing and Alternate Table Lookup Techniques Prepared by The syntax for data step merging is as follows: International SAS Training and Consulting This assumes that the incoming data sets are

More information

Moving Data and Results Between SAS and Excel. Harry Droogendyk Stratia Consulting Inc.

Moving Data and Results Between SAS and Excel. Harry Droogendyk Stratia Consulting Inc. Moving Data and Results Between SAS and Excel Harry Droogendyk Stratia Consulting Inc. Introduction SAS can read ( and write ) anything Introduction In the end users want EVERYTHING in. Introduction SAS

More information

SAS CURRICULUM. BASE SAS Introduction

SAS 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 information

Getting 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 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 information

Syntax Conventions for SAS Programming Languages

Syntax Conventions for SAS Programming Languages Syntax Conventions for SAS Programming Languages SAS Syntax Components Keywords A keyword is one or more literal name components of a language element. Keywords are uppercase, and in reference documentation,

More information

Importing CSV Data to All Character Variables Arthur L. Carpenter California Occidental Consultants, Anchorage, AK

Importing CSV Data to All Character Variables Arthur L. Carpenter California Occidental Consultants, Anchorage, AK PharmaSUG 2017 QT02 Importing CSV Data to All Character Variables Arthur L. Carpenter California Occidental Consultants, Anchorage, AK ABSTRACT Have you ever needed to import data from a CSV file and found

More information

Reading in Data Directly from Microsoft Word Questionnaire Forms

Reading in Data Directly from Microsoft Word Questionnaire Forms Paper 1401-2014 Reading in Data Directly from Microsoft Word Questionnaire Forms Sijian Zhang, VA Pittsburgh Healthcare System ABSTRACT If someone comes to you with hundreds of questionnaire forms in Microsoft

More information

Procedure for Stamping Source File Information on SAS Output Elizabeth Molloy & Breda O'Connor, ICON Clinical Research

Procedure for Stamping Source File Information on SAS Output Elizabeth Molloy & Breda O'Connor, ICON Clinical Research Procedure for Stamping Source File Information on SAS Output Elizabeth Molloy & Breda O'Connor, ICON Clinical Research ABSTRACT In the course of producing a report for a clinical trial numerous drafts

More information

Create a Format from a SAS Data Set Ruth Marisol Rivera, i3 Statprobe, Mexico City, Mexico

Create a Format from a SAS Data Set Ruth Marisol Rivera, i3 Statprobe, Mexico City, Mexico PharmaSUG 2011 - Paper TT02 Create a Format from a SAS Data Set Ruth Marisol Rivera, i3 Statprobe, Mexico City, Mexico ABSTRACT Many times we have to apply formats and it could be hard to create them specially

More information

Template Versatility Using SAS Macro Language to Generate Dynamic RTF Reports Patrick Leon, MPH

Template Versatility Using SAS Macro Language to Generate Dynamic RTF Reports Patrick Leon, MPH Versatility Using SAS Macro Language to Generate Dynamic RTF Reports Versatility Using SAS Macro Language to Generate Dynamic RTF Reports ABSTRACT SAS Macro Language can be used to enhance many report-generating

More information

Eventus Example Series Using Non-CRSP Data in Eventus 7 1

Eventus Example Series Using Non-CRSP Data in Eventus 7 1 Eventus Example Series Using Non-CRSP Data in Eventus 7 1 Goal: Use Eventus software version 7.0 or higher to construct a mini-database of data obtained from any source, and run one or more event studies

More information

17. Reading free-format data. GIORGIO RUSSOLILLO - Cours de prépara)on à la cer)fica)on SAS «Base Programming» 386

17. Reading free-format data. GIORGIO RUSSOLILLO - Cours de prépara)on à la cer)fica)on SAS «Base Programming» 386 17. Reading free-format data 386 Reading free format data: The list input A raw dataset is free-format when it is not arranged in fixed fields. -> Fields are separated by a delimiter List input allows

More information

April 4, SAS General Introduction

April 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 information

MATH 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, (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 information

Basic Concept Review

Basic Concept Review Basic Concept Review Quiz Using the Programming Workspace Referencing Files and Setting Options Editing and Debugging SAS Programs End of Review SAS Format Format Formats are variable

More information

Validating And Updating Your Data Using SAS Formats Peter Welbrock, Britannia Consulting, Inc., MA

Validating And Updating Your Data Using SAS Formats Peter Welbrock, Britannia Consulting, Inc., MA Validating And Updating Your Data Using SAS Formats Peter Welbrock, Britannia Consulting, Inc., MA Overview In whatever way you use SAS software, at some point you will have to deal with data. It is unavoidable.

More information

Using SAS Files CHAPTER 3

Using SAS Files CHAPTER 3 55 CHAPTER 3 Using SAS Files Introduction to SAS Files 56 What Is a SAS File? 56 Types of SAS Files 57 Using Short or Long File Extensions in SAS Libraries 58 SAS Data Sets (Member Type: Data or View)

More information

Chapter 1 The DATA Step

Chapter 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 information

MISSOVER, TRUNCOVER, and PAD, OH MY!! or Making Sense of the INFILE and INPUT Statements. Randall Cates, MPH, Technical Training Specialist

MISSOVER, TRUNCOVER, and PAD, OH MY!! or Making Sense of the INFILE and INPUT Statements. Randall Cates, MPH, Technical Training Specialist MISSOVER, TRUNCOVER, and PAD, OH MY!! or Making Sense of the INFILE and INPUT Statements. Randall Cates, MPH, Technical Training Specialist ABSTRACT The SAS System has many powerful tools to store, analyze

More information

Intermediate SAS: Working with Data

Intermediate SAS: Working with Data Intermediate SAS: Working with Data OIT Technical Support Services 293-4444 oithelp@mail.wvu.edu oit.wvu.edu/training/classmat/sas/ Table of Contents Getting set up for the Intermediate SAS workshop:...

More information

Introduction to SAS Statistical Package

Introduction to SAS Statistical Package Instructor: Introduction to SAS Statistical Package Biostatistics 140.632 Lecture 1 Lucy Meoni lmeoni@jhmi.edu Teaching Assistant : Sorina Eftim seftim@jhsph.edu Lecture/Lab: Room 3017 WEB site: www.biostat.jhsph.edu/bstcourse/bio632/default.htm

More information

22S:166. Checking Values of Numeric Variables

22S: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 information

Procedures. PROC CATALOG CATALOG=<libref.>catalog <ENTRYTYPE=etype> <KILL>; CONTENTS <OUT=SAS-data-set> <FILE=fileref;>

Procedures. PROC CATALOG CATALOG=<libref.>catalog <ENTRYTYPE=etype> <KILL>; CONTENTS <OUT=SAS-data-set> <FILE=fileref;> 355 CHAPTER 19 Procedures SAS Procedures under Windows 355 CATALOG 355 CIMPORT 356 CONTENTS 357 CONVERT 358 CPORT 361 DATASETS 361 OPTIONS 363 PMENU 364 PRINTTO 365 SORT 367 SAS Procedures under Windows

More information

An Introduction to SAS University Edition

An 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 information

APPENDIX 4 Migrating from QMF to SAS/ ASSIST Software. Each of these steps can be executed independently.

APPENDIX 4 Migrating from QMF to SAS/ ASSIST Software. Each of these steps can be executed independently. 255 APPENDIX 4 Migrating from QMF to SAS/ ASSIST Software Introduction 255 Generating a QMF Export Procedure 255 Exporting Queries from QMF 257 Importing QMF Queries into Query and Reporting 257 Alternate

More information

STAT 7000: Experimental Statistics I

STAT 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 information

Using DDE with Microsoft Excel and SAS to Collect Data from Hundreds of Users

Using DDE with Microsoft Excel and SAS to Collect Data from Hundreds of Users Using DDE with Microsoft Excel and SAS to Collect Data from Hundreds of Users Russell Denslow and Yan Li Sodexho Marriott Services, Orlando, FL ABSTRACT A process is demonstrated in this paper to automatically

More information

The INPUT Statement: Where It

The INPUT Statement: Where It The INPUT Statement: Where It s @ Ron Cody email: ron.cody@gmail.com Author page: Support.sas.com/cody List Directed Input data list input X Y A $ Z datalines 1 2 hello 3 4 5 goodbye 6 title 'List Directed

More information

PHPM 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 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 information

Formats and the Format Procedure

Formats and the Format Procedure Formats and the Format Procedure Assigning Formats for Display While labels are used to change how a variable name is displayed, formats are used to change how data values are displayed. Formats are assigned

More information

Exporting & Importing Datasets & Catalogs: Utility Macros

Exporting & Importing Datasets & Catalogs: Utility Macros Exporting & Importing Datasets & Catalogs: Utility Macros Adel Fahmy, SYSMART Consulting, North Brunswick, NJ ABSTRACT Since different companies use different SAS versions installed on different platforms,

More information

Macros to Manage your Macros? Garrett Weaver, University of Southern California, Los Angeles, CA

Macros to Manage your Macros? Garrett Weaver, University of Southern California, Los Angeles, CA Macros to Manage your Macros? Garrett Weaver, University of Southern California, Los Angeles, CA ABSTRACT SAS currently offers several methods for users to store and retrieve user-generated macros. The

More information

Top-Down Programming with SAS Macros Edward Heaton, Westat, Rockville, MD

Top-Down Programming with SAS Macros Edward Heaton, Westat, Rockville, MD Paper P813 Top-Down Programming with SAS Macros Edward Heaton, Westat, Rockville, MD ABSTRACT Structured, top-down programming techniques are not intuitively obvious in the SAS language, but macros can

More information

PROC FORMAT. CMS SAS User Group Conference October 31, 2007 Dan Waldo

PROC FORMAT. CMS SAS User Group Conference October 31, 2007 Dan Waldo PROC FORMAT CMS SAS User Group Conference October 31, 2007 Dan Waldo 1 Today s topic: Three uses of formats 1. To improve the user-friendliness of printed results 2. To group like data values without affecting

More information

Exchanging data between SAS and Microsoft Excel

Exchanging data between SAS and Microsoft Excel Paper CC 011 Exchanging data between SAS and Microsoft Excel Yuqing Xiao, Southern Company, Atlanta, GA ABSTRACT Transferring data between SAS and Microsoft Excel has gained popularity over the years.

More information

Use That SAP to Write Your Code Sandra Minjoe, Genentech, Inc., South San Francisco, CA

Use That SAP to Write Your Code Sandra Minjoe, Genentech, Inc., South San Francisco, CA Paper DM09 Use That SAP to Write Your Code Sandra Minjoe, Genentech, Inc., South San Francisco, CA ABSTRACT In this electronic age we live in, we usually receive the detailed specifications from our biostatistician

More information

Paper SAS Programming Conventions Lois Levin, Independent Consultant, Bethesda, Maryland

Paper SAS Programming Conventions Lois Levin, Independent Consultant, Bethesda, Maryland Paper 241-28 SAS Programming Conventions Lois Levin, Independent Consultant, Bethesda, Maryland ABSTRACT This paper presents a set of programming conventions and guidelines that can be considered in developing

More information

SAS Certification Handout #6: Ch

SAS Certification Handout #6: Ch SAS Certification Handout #6: Ch. 16-18 /************ Ch. 16 ******************* /* Suppose we have numeric variables ModelNumber Price Weight Change and date variable Date, plus a string variable Designer

More information

SAS Programming Conventions Lois Levin, Independent Consultant

SAS Programming Conventions Lois Levin, Independent Consultant SAS Programming Conventions Lois Levin, Independent Consultant INTRODUCTION This paper presents a set of programming conventions and guidelines that can be considered in developing code to ensure that

More information

Learn to Impress - Hidden base SAS features. Peter Crawford Crawford Software Consultancy Limited 1 of 21

Learn to Impress - Hidden base SAS features. Peter Crawford Crawford Software Consultancy Limited 1 of 21 Peter Crawford Crawford Software Consultancy Limited 1 of 21 Learn hidden features in base SAS to impress colleagues Peter Crawford So many features So much to learn So much being added to SAS languages

More information

Introduction to the SAS System

Introduction 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 information

Introduction to SAS. Hsueh-Sheng Wu. Center for Family and Demographic Research. November 1, 2010

Introduction to SAS. Hsueh-Sheng Wu. Center for Family and Demographic Research. November 1, 2010 Introduction to SAS Hsueh-Sheng Wu Center for Family and Demographic Research November 1, 2010 1 Outline What is SAS? Things you need to know before using SAS SAS user interface Using SAS to manage data

More information

BASICS BEFORE STARTING SAS DATAWAREHOSING Concepts What is ETL ETL Concepts What is OLAP SAS. What is SAS History of SAS Modules available SAS

BASICS BEFORE STARTING SAS DATAWAREHOSING Concepts What is ETL ETL Concepts What is OLAP SAS. What is SAS History of SAS Modules available SAS SAS COURSE CONTENT Course Duration - 40hrs BASICS BEFORE STARTING SAS DATAWAREHOSING Concepts What is ETL ETL Concepts What is OLAP SAS What is SAS History of SAS Modules available SAS GETTING STARTED

More information

STAT:5400 Computing in Statistics

STAT: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 information

Matt Downs and Heidi Christ-Schmidt Statistics Collaborative, Inc., Washington, D.C.

Matt Downs and Heidi Christ-Schmidt Statistics Collaborative, Inc., Washington, D.C. Paper 82-25 Dynamic data set selection and project management using SAS 6.12 and the Windows NT 4.0 file system Matt Downs and Heidi Christ-Schmidt Statistics Collaborative, Inc., Washington, D.C. ABSTRACT

More information

Lecture 1 Getting Started with SAS

Lecture 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 information

Introduction OR CARDS. INPUT DATA step OUTPUT DATA 8-1

Introduction OR CARDS. INPUT DATA step OUTPUT DATA 8-1 Introduction Thus far, all the DATA step programs we have seen have involved reading and writing only SAS data sets. In this chapter we will present techniques to read and write external or "raw" files

More information

A Macro that can Search and Replace String in your SAS Programs

A Macro that can Search and Replace String in your SAS Programs ABSTRACT MWSUG 2016 - Paper BB27 A Macro that can Search and Replace String in your SAS Programs Ting Sa, Cincinnati Children s Hospital Medical Center, Cincinnati, OH In this paper, a SAS macro is introduced

More information

SUGI 29 Data Warehousing, Management and Quality

SUGI 29 Data Warehousing, Management and Quality Building a Purchasing Data Warehouse for SRM from Disparate Procurement Systems Zeph Stemle, Qualex Consulting Services, Inc., Union, KY ABSTRACT SAS Supplier Relationship Management (SRM) solution offers

More information

Biostatistics 600 SAS Lab Supplement 1 Fall 2012

Biostatistics 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 information

SAS Online Training: Course contents: Agenda:

SAS 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 information

TOP 10 (OR MORE) WAYS TO OPTIMIZE YOUR SAS CODE

TOP 10 (OR MORE) WAYS TO OPTIMIZE YOUR SAS CODE TOP 10 (OR MORE) WAYS TO OPTIMIZE YOUR SAS CODE Handy Tips for the Savvy Programmer SAS PROGRAMMING BEST PRACTICES Create Readable Code Basic Coding Recommendations» Efficiently choosing data for processing»

More information

SAS Macro Programming for Beginners

SAS Macro Programming for Beginners ABSTRACT SAS Macro Programming for Beginners Lora D. Delwiche, Winters, CA Susan J. Slaughter, Avocet Solutions, Davis, CA Macro programming is generally considered an advanced topic. But, while macros

More information

What Is SAS? CHAPTER 1 Essential Concepts of Base SAS Software

What Is SAS? CHAPTER 1 Essential Concepts of Base SAS Software 3 CHAPTER 1 Essential Concepts of Base SAS Software What Is SAS? 3 Overview of Base SAS Software 4 Components of the SAS Language 4 SAS Files 4 SAS Data Sets 5 External Files 5 Database Management System

More information

BIOMETRICS INFORMATION

BIOMETRICS INFORMATION BIOMETRICS INFORMATION (You re 95% likely to need this information) PAMPHLET NO. # 24 DATE: February 9, 1990 SUBJECT: Reading WATFILE files into SAS WATFILE is a useful package for data entry because it

More information

Writing Programs in SAS Data I/O in SAS

Writing 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 information

Customizing Your SAS Session

Customizing 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 information

Review of PC-SAS Batch Programming

Review of PC-SAS Batch Programming Ronald J. Fehd September 21, 2007 Abstract This paper presents an overview of issues of usage of PC-SAS R in a project directory. Topics covered include directory structures, how to start SAS in a particular

More information

AN INTRODUCTION TO MACRO VARIABLES AND MACRO PROGRAMS Mike Zdeb, School of Public Health

AN 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 information

Chapter 7 File Access. Chapter Table of Contents

Chapter 7 File Access. Chapter Table of Contents Chapter 7 File Access Chapter Table of Contents OVERVIEW...105 REFERRING TO AN EXTERNAL FILE...105 TypesofExternalFiles...106 READING FROM AN EXTERNAL FILE...107 UsingtheINFILEStatement...107 UsingtheINPUTStatement...108

More information

A Time Saver for All: A SAS Toolbox Philip Jou, Baylor University, Waco, TX

A Time Saver for All: A SAS Toolbox Philip Jou, Baylor University, Waco, TX South Central SAS Users Group 2016 A Time Saver for All: A SAS Toolbox Philip Jou, Baylor University, Waco, TX ABSTRACT SAS Macros are a useful tool to any SAS Programmer. A macro variable can be used

More information

Using a Control Dataset to Manage Production Compiled Macro Library Curtis E. Reid, Bureau of Labor Statistics, Washington, DC

Using a Control Dataset to Manage Production Compiled Macro Library Curtis E. Reid, Bureau of Labor Statistics, Washington, DC AP06 Using a Control Dataset to Manage Production Compiled Macro Library Curtis E. Reid, Bureau of Labor Statistics, Washington, DC ABSTRACT By default, SAS compiles and stores all macros into the WORK

More information

ERROR: ERROR: ERROR:

ERROR: 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 information

IT 433 Final Exam. June 9, 2014

IT 433 Final Exam. June 9, 2014 Page 1 of 10 IT 433 Final Exam June 9, 2014 Part A: Multiple Choice Questions about SAS. Circle the most correct answer for each question. You may give an optional reason for each answer; if the answer

More information

Week 9: PROC TABULATE (Chapter 19)

Week 9: PROC TABULATE (Chapter 19) Week 9: PROC TABULATE (Chapter 19) We continue exploring primarily describing data to make it easier to present and understand. PROC TABULATE is especially useful for qualitative variables or for breaking

More information

SAS/FSP 9.2. Procedures Guide

SAS/FSP 9.2. Procedures Guide SAS/FSP 9.2 Procedures Guide The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2008. SAS/FSP 9.2 Procedures Guide. Cary, NC: SAS Institute Inc. SAS/FSP 9.2 Procedures

More information

Dictionary.coumns is your friend while appending or moving data

Dictionary.coumns is your friend while appending or moving data ABSTRACT SESUG Paper CC-41-2017 Dictionary.coumns is your friend while appending or moving data Kiran Venna, Dataspace Inc. Dictionary.columns is a dictionary table, which gives metadata information of

More information

Implementing User-Friendly Macro Systems Ed Heaton Data & Analytic Solutions, Inc. Sarah Woodruff Westat

Implementing User-Friendly Macro Systems Ed Heaton Data & Analytic Solutions, Inc. Sarah Woodruff Westat Implementing User-Friendly Macro Systems Ed Heaton Data & Analytic Solutions, Inc. Sarah Woodruff Westat SAS facilitates macro libraries through the autocall facility and compiled macro catalogs. These

More information

Level I: Getting comfortable with my data in SAS. Descriptive Statistics

Level 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 information

STATION

STATION ------------------------------STATION 1------------------------------ 1. Which of the following statements displays all user-defined macro variables in the SAS log? a) %put user=; b) %put user; c) %put

More information

Help, I've Received a Spreadsheet File from StarOffice Calc...!

Help, I've Received a Spreadsheet File from StarOffice Calc...! Help, I've Received a Spreadsheet File from StarOffice Calc...! Author: Philip R Holland, Holland Numerics Ltd Abstract We have been conditioned to accept spreadsheet files from Excel, which require SAS/ACCESS

More information

SAS Certification Handout #7: Ch

SAS Certification Handout #7: Ch SAS Certification Handout #7: Ch. 19-21 /************ Ch. 19 ********************/ /* Consider a mailing list example, partial from http://mlb.mlb.com/team/ 1---+----10---+----20---+ Kansas City Royals

More information