SAS 101. Based on Learning SAS by Example: A Programmer s Guide Chapters 9, 11 & 12. 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 Chapters 9, 11 & 12. By Tasha Chapman, Oregon Health Authority"

Transcription

1 SAS 101 Based on Learning SAS by Example: A Programmer s Guide Chapters 9, 11 & 12 By Tasha Chapman, Oregon Health Authority

2 Topics covered SAS dates Date functions Numeric functions Character functions Special functions PUT and INPUT

3 SAS dates

4 SAS dates Dates are stored as the number of days from January 1 st, 1960 Dates before 1960 are negative numbers Dates after 1960 are positive numbers Examples: 1/1/1960 = 0 1/2/1960 = 1 10/21/1950 = -3,359 12/31/2012 = 19,358

5 SAS dates Times are stored as the number of seconds from midnight Times are always positive Examples: Midnight = 0 Midnight and 36 seconds = 36 5:38am and 9 seconds= 20,289 12:51pm and 2 seconds = 46,262

6 SAS dates Datetime values are stored as the number of seconds from 1/1/1960 Datetimes before 1960 are negative numbers Datetimes after 1960 are positive numbers Examples: 1/1/1960 at midnight and 36 seconds = 36 1/2/1960 at 5:38am and 9 seconds = 106,689 10/21/1950 at 12:51pm & 2 secs = -290,171,338 12/31/2012 at midnight = 1,672,531,200

7 Common date formats/informats If you input 14686: Format Result MMDDYY10. 03/17/2000 MMDDYY8. 03/17/00 MONNAME. March YEAR MONYY. MAR2000 WORDDATE. March 17, 2000 WEEKDATE. Friday, March 17, 2000 DOWNAME. Friday QTR. 1 YYQ. 2000Q1

8 Common date formats/informats If you input 14686: Format Result MMDDYY10. 03/17/2000 MMDDYY8. 03/17/00 MONNAME. March YEAR MONYY. MAR2000 WORDDATE. March 17, 2000 WEEKDATE. Friday, March 17, 2000 DOWNAME. Friday QTR. 1 YYQ. 2000Q1

9 Examples of date formats SAS Documentation

10 Using dates Date constants can be used in IF and WHERE statements, functions, and other portions of your SAS code These are written as: 'DDMONCCYY'd

11 Using dates The current date can be computed using the TODAY() function

12 Using dates Datetime constants can be also be used in your SAS code These are written as: 'DDMONCCYY:HH:MM:SS'dt

13 Using dates BEWARE! If your database stores datetime variables 1,441,193,037 '30sep2005:11:23:57'dt is the not same thing as '30sep2005'd 16,709 30sep2005:00:00:00 dt

14 Using dates BEWARE! If your database stores datetime variables '01sep2005'd le mod_date le '30sep2005'd may ignore datetime values on September 30 th with non-zero times

15 Using dates BEWARE! If your database stores datetime variables Alternatives: '01sep2005:00:00:00'dt le mod_date le '30sep2005:23:59:59'dt

16 Using dates BEWARE! If your database stores datetime variables Alternatives: '01sep2005'd le mod_date lt '01oct2005'd * This option does not work with a SAS dataset

17 Reading dates from raw data Informat works fine if you know the format of the incoming data and the data is consistent but what if the data is wonky?

18 Reading dates from raw data Dates come in all shapes and sizes, sometimes even in the same data file How do we deal with them all?

19 Reading dates from raw data Use anydtdte. informat to deal with wonky date data.

20 Reading dates from raw data Informat anydtdte. anydtdtm. anydttme. Purpose Extracts the date portion Extracts the datetime portion Extracts the time portion

21 Reading dates from raw data When reading a two-digit year, SAS uses a 100- year interval to determine which century the year belongs to Default is 1920 Use yearcutoff= system option to change default

22 Reading dates from raw data

23 Reading dates from raw data

24 Functions

25 What are functions? function(argument-1, argument-2) Functions return a value from a computation or system manipulation based on supplied arguments Arguments can be constants, variables, or expressions, depending on the function Can nest functions within functions Most often use functions to create new variables or as part of conditional logic

26 Functions vs. PROCs Functions vs. PROCs Functions calculate across variables (one value per observation) PROCs calculate down observations (one value per dataset) Would provide a single score per student that averages all of his/her test scores Would provide an average score for all students for test 1 Graphic from Introduction to SAS Functions by Neil Howard

27 Examples of functions SAS Documentation

28 Date functions

29 Date functions

30 Date functions Function Purpose Sample Output datepart(datetime); Extract date portion from a datetime value timepart(datetime); Extract time portion from a datetime value year(date); Extract year from a date value 2009 month(date); Extract month from a date value 12 day(date); Extract day of the month from a date value 31 weekday(date); Extract day of the week from a date value 2 mdy(month, day, year); Create a date using month, day and year values 17905

31 Date functions Function Purpose Sample Output datepart(datetime); Extract date portion from a datetime value timepart(datetime); Extract time portion from a datetime value year(date); Extract year from a date value 2009 month(date); Extract month from a date value 12 day(date); Extract day of the month from a date value 31 weekday(date); Extract day of the week from a date value 2 mdy(month, day, year); Create a date using month, day and year values 17905

32 Date functions Many uses of functions

33 INTCK function INTCK(interval, from, to) Returns a count of the number of interval boundaries between two dates, times, or datetime values interval : desired interval Examples: 'YEAR' 'MONTH' 'DAY' 'QTR' from : Starting date, time, or datetime value to : Ending date, time, or datetime value

34 INTCK function Interval counted each time a boundary is crossed Interval Boundary 'YEAR' January 1 'MONTH' 'DAY' First of any month Start of each day 'QTR' January 1, April 1, July 1, and October 1

35 INTCK function Examples of INTCK Function Result intck('day', '01jan2013'd, '01jan2013'd) 0 intck('day', '01jan2013'd, '02jan2013'd) 1 intck('year', '01jan2013'd, '01apr2013'd) 0 intck('year', '01dec2012'd, '01apr2013'd) 1 intck('year', '01jan2013'd, '01apr2014'd) 1

36 INTCK function Examples of INTCK Function Result intck('day', '01jan2013'd, '01jan2013'd) 0 intck('day', '01jan2013'd, '02jan2013'd) 1 intck('year', '01jan2013'd, '01apr2013'd) 0 intck('year', '01dec2012'd, '01apr2013'd) 1 intck('year', '01jan2013'd, '01apr2014'd) 1

37 INTCK function Can use INTCK function to classify observations

38 Frequency of admissions INTCK function 1200 Hospital Admissions by Quarter January 1, 2003 through June 30, Calendar quarter

39 Calculating age Different methods produce different results Most commonly recognized

40 INTNX function INTNX(interval, from, n, <alignment>) Increments a date, time, or dateime value by a given interval interval : desired interval from : Starting date, time, or datetime value n : number of interval increments Can be positive, negative, or zero alignment : optional argument that controls the alignment of the date 'SAMEDAY', 'BEGINNING', 'MIDDLE', or 'END Default is 'BEGINNING'

41 INTNX function Examples of INTNX Function Result intnx('day', '01jan2013'd, 3) 01/04/2013 intnx('year', '25jan2013'd, 1) 01/01/2014 intnx('year', '30aug2012'd, -31) 01/01/1981 intnx('year', '30aug2012'd, -31, 'SAMEDAY') 08/30/1981

42 INTNX function Examples of INTNX Function Result intnx('day', '01jan2013'd, 3) 01/04/2013 intnx('year', '25jan2013'd, 1) 01/01/2014 intnx('year', '30aug2012'd, -31) 01/01/1981 intnx('year', '30aug2012'd, -31, 'SAMEDAY') 08/30/1981

43 INTNX function Can use INTNX function to help automate reports

44 Numeric functions

45 ROUND function ROUND(argument, <rounding-unit>) Rounds a number to the selected rounding unit argument : numeric value to be rounded rounding-unit : optional increment for rounding Default is 1 (nearest integer) Function Result round( , 1) 157 round( , 10) 160 round( ,.01)

46 INT function INT(argument) Truncates argument to an integer value (drops the decimal point) argument : numeric value to be truncated Function Result int( ) 156

47 Descriptive stats functions Two methods: function(var1, var2, varn) function(of var1-varn) Can use these methods separately or together Function (example) N(Q1, Q2, Q3, Q4) Mean(of Q1-Q4) Sum(0, of Q1-Q4) Min(of Q1-Q4) Max(of Q1-Q4) Result Returns the number of non-missing numeric values Returns the arithmetic mean (average) Returns the sum of nonmissing values (in this example, if all arguments are missing, returns 0) Returns the smallest value Returns the largest value

48 RANUNI function RANUNI(seed) Generates a random number between 0 and 1 seed : a number which is used to generate the first number in the random sequence Can be any number If you use a seed of 0 or negative number, SAS will use the system clock to supply the seed Function ranuni( ) Result Returns a random number

49 LAG function LAG<n>(argument) Return value from a previous observation (generally) n : specifies the number of lagged values argument : number, expression or variable to be lagged

50 LAG function DIF function similar to LAG Returns the difference between current value and previous value i.e. DIF(x) = x lag(x)

51 LAG function

52 Character functions

53 CASE functions Converts character string to upper or lower case Function (example) upcase('sas rocks') lowcase('i AM WHISPERING') Result SAS ROCKS i am whispering Useful when using comparison operators

54 PROPCASE function PROPCASE(argument, <delimiters>) Converts all words to proper case argument : character value that will be converted delimiters : specifies one or more delimiters that indicate the beginning of a new word Enclose delimiters in quotation marks Default delimiters are blank, forward slash, hyphen, open parenthesis, period, and tab Use of option overrides all default delimiters Function propcase('saint KITTS/NEVIS(U.S.)') propcase("george O'KEEFE-BAIN", " '-"); Result Saint Kitts/Nevis(U.S.) George O Keefe-Bain

55 SUBSTR function SUBSTR(string, position, <length>) Extracts a substring (portion) of text string : character value that text will be extracted from position : beginning character position for substring length : length of substring to extract If omitted, SAS extracts the remainder of the string Function Result substr('jeff STREET', 5) STREET substr('621110', 1, 2) 62 substr('dr. Paul Jones', 5, 4) Paul

56 SCAN function SCAN(string, count, <charlist, <mods>>) Returns the nth word from a character string string : character value that words will be pulled from count : integer that specifies the number of the word to select Positive counts from left to right Negative counts from right to left charlist : optional delimiter identifier modifiers : optional modifier that changes the behavior of the SCAN function Function scan('jeff STREET', 2) Result STREET

57 CAT function Function cat('john', 'Smith') CAT(item1, item2, itemn) Concatenates items into a single character string items : value to be concatenated If numeric, value is first converted to character Can also be written as: CAT(of item1-itemn) cat('i', ' ', 'Heart', ' ', 'You') Result JohnSmith I Heart You cat('(', area, ')', prefix, '-', suffix) (503) cat(1225, ' Ferry St.') 1225 Ferry St.

58 COMPRESS function COMPRESS(<source>, <chars>, <modifiers>) Removes specified characters from a string source : character value from which characters will be removed chars : characters to be removed If omitted, only blanks will be removed modifiers : optional modifier that changes the behavior of the COMPRESS function Function( Result compress('mc Cartney') McCartney compress('(503) ', '()- ')

59 Special functions PUT and INPUT

60 PUT function PUT(source, format.) Returns a value using a specified format Most often used for converting numeric data to character source : value to be reformatted format : the format to be applied The format must be the same type as the source (character/numeric) Function Result put(patient_id, 8.) A patient ID that is character put(32000, dollar24.) $32,000 put(16739, date9.) put('m', $gender.) 30OCT2005 Male

61 PUT function PUT function vs. Format statements: Format statements change the appearance of the value PUT functions change the value itself Date and Char_Date look the same, but one is character and the other is numeric.

62 INPUT function INPUT(source, <???> informat.) Converts a value using a specified informat Most often used for converting character data to numeric source : value to be reformatted??? : Optional modifiers that suppress error messages informat : the informat to be applied Function Result input('32000', 5.) input('32000', 5.2) input('$ ', dollar24.2) input('30oct2005', date9.) 16739

63 For next week Read chapters 14 & 19

Welcome to Top 10 SAS Functions

Welcome to Top 10 SAS Functions Welcome to Top 10 SAS Functions Goal and Agenda By the end of this meeting, you will understand 10 key SAS functions purpose, value and features. What are SAS functions? Why use them? Use Case Manipulating

More information

Dating for SAS Programmers

Dating for SAS Programmers ABSTRACT Dating for SAS Programmers Joshua M. Horstman, Nested Loop Consulting Every SAS programmer needs to know how to get a date... no, not that kind of date. This paper will cover the fundamentals

More information

Beginning Tutorials DATE HANDLING IN THE SAS SYSTEM. Bruce Gilsen, Federal Reserve Board

Beginning Tutorials DATE HANDLING IN THE SAS SYSTEM. Bruce Gilsen, Federal Reserve Board DATE HANDLING IN THE SAS SYSTEM Bruce Gilsen, Federal Reserve Board 1. Introduction A calendar date can be represented in the SAS system as a SAS date value, a special representation of a calendar date

More information

Arthur L. Carpenter California Occidental Consultants

Arthur L. Carpenter California Occidental Consultants Paper 255-30 Looking for a Date? A Tutorial on Using SAS Dates and Times Arthur L. Carpenter California Occidental Consultants ABSTRACT What are SAS date and time values? How are they used and why do we

More information

Introduction to SAS Mike Zdeb ( , #83

Introduction to SAS Mike Zdeb ( , #83 Mike Zdeb (402-6479, msz03@albany.edu) #83 (8) DATES SAS has numerous informats for reading dates and formats for displaying dates. Dates can be read with either numeric, character, or date informats.

More information

WORKING WITH SAS DATE AND TIME FUNCTIONS Andrew H. Karp Sierra Information Services, Inc. San Francisco, California USA

WORKING WITH SAS DATE AND TIME FUNCTIONS Andrew H. Karp Sierra Information Services, Inc. San Francisco, California USA WORKING WITH SAS DATE AND TIME FUNCTIONS Andrew H. Karp Sierra Information Services, Inc. San Francisco, California USA Introduction Many SAS applications require that operations be performed on data collected

More information

Top 10 SAS Functions in A brief summary of SAS Communities Survey - by Flora Fang Liu

Top 10 SAS Functions in A brief summary of SAS Communities Survey - by Flora Fang Liu Top 10 SAS Functions in 2017 A brief summary of SAS Communities Survey - by Flora Fang Liu 1 What are SAS Functions? Why use SAS Functions? What? SAS functions perform computations, data manipulation,

More information

Getting the Right DATES

Getting the Right DATES Getting the Right DATES Marje Fecht Senior Partner, Prowerk Consulting SAS Global Forum 2014 Conference Chair Copyright 2012 Prowerk Consulting 1 Getting the RIGHT Date can be Tricky This presentation

More information

Basic Concepts #4. Data Step #3: Reading a SAS Data Set and Functions and Call Routines. JC Wang

Basic Concepts #4. Data Step #3: Reading a SAS Data Set and Functions and Call Routines. JC Wang Basic Concepts #4 Data Step #3: Reading a SAS Data Set and Functions and Call Routines JC Wang SET Statement SET SAS-data-name; Selected data-set-options: KEEP=/DROP= to read only wanted

More information

18. Reading date and )me values. GIORGIO RUSSOLILLO - Cours de prépara)on à la cer)fica)on SAS «Base Programming» 394

18. Reading date and )me values. GIORGIO RUSSOLILLO - Cours de prépara)on à la cer)fica)on SAS «Base Programming» 394 18. Reading date and )me values 394 How SAS stores date values - A SAS date value is stored as the number of days from January 1, 1960, to the given date - A SAS Bme value is stored as the number of seconds

More information

Have a Strange DATE? Create your own INFORMAT to Deal with Her Venky Chakravarthy, Ann Arbor, MI

Have a Strange DATE? Create your own INFORMAT to Deal with Her Venky Chakravarthy, Ann Arbor, MI Have a Strange DATE? Create your own INFORMAT to Deal with Her Venky Chakravarthy, Ann Arbor, MI ABSTRACT Whatever the title may lead you to believe, this is a serious discussion of dates that are strange

More information

The Year argument can be one to four digits between 1 and Month is a number representing the month of the year between 1 and 12.

The Year argument can be one to four digits between 1 and Month is a number representing the month of the year between 1 and 12. The table below lists all of the Excel -style date and time functions provided by the WinCalcManager control, along with a description and example of each function. FUNCTION DESCRIPTION REMARKS EXAMPLE

More information

Demystifying Intervals

Demystifying Intervals MWSUG 2017 Paper BB042 Demystifying Intervals Derek Morgan, PAREXEL International, Billerica, MA ABSTRACT Intervals have been a feature of base SAS for a long time, allowing SAS users to work with commonly

More information

SAS Certification Handout #5: Ch /************ Ch. 13 ********************/ /* NOTE: Ch. 13 presents loads of functions; see pp.

SAS Certification Handout #5: Ch /************ Ch. 13 ********************/ /* NOTE: Ch. 13 presents loads of functions; see pp. SAS Certification Handout #5: Ch. 13-15 /************ Ch. 13 ********************/ /* NOTE: Ch. 13 presents loads of functions see pp. 452-455 */ /* MEAN function */ data a5 input X1-X5 Xmeans = mean(of

More information

All About SAS Dates. Marje Fecht Senior Partner, Prowerk Consulting. Copyright 2017 Prowerk Consulting

All About SAS Dates. Marje Fecht Senior Partner, Prowerk Consulting. Copyright 2017 Prowerk Consulting All About SAS Dates Marje Fecht Senior Partner, Prowerk Consulting Copyright 2017 Prowerk Consulting 1 SAS Dates What IS a SAS Date? And Why?? My data aren t stored as SAS Dates How can I convert How can

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

Title for SAS Global Forum 2014 Sample Paper

Title for SAS Global Forum 2014 Sample Paper Paper 1623-2014 Title for SAS Global Forum 2014 Sample Paper Jenine Milum, Equifax Inc. ABSTRACT No matter how long you ve been programming in SAS, using and manipulating dates still seems to require effort.

More information

WKn Chapter. Note to UNIX and OS/390 Users. Import/Export Facility CHAPTER 9

WKn Chapter. Note to UNIX and OS/390 Users. Import/Export Facility CHAPTER 9 117 CHAPTER 9 WKn Chapter Note to UNIX and OS/390 Users 117 Import/Export Facility 117 Understanding WKn Essentials 118 WKn Files 118 WKn File Naming Conventions 120 WKn Data Types 120 How the SAS System

More information

The TIMEPLOT Procedure

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

MARK CARPENTER, Ph.D.

MARK CARPENTER, Ph.D. MARK CARPENTER, Ph.D. Module 5 : SAS Functions Introduction to SAS Programming and Applications Descrip(on. In this module, we with various SAS Func7ons, including numerical func7ons, date func7ons and

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

The Essentials of SAS Dates and Times Derek Morgan, Covidien

The Essentials of SAS Dates and Times Derek Morgan, Covidien The Essentials of SAS Dates and Times Derek Morgan, Covidien ABSTRACT The first thing you need to know is that SAS software stores dates and times as numbers. However, this is not the only thing that you

More information

Stat 302 Statistical Software and Its Applications SAS Functions

Stat 302 Statistical Software and Its Applications SAS Functions Stat 302 Statistical Software and Its Applications SAS Functions Yen-Chi Chen Department of Statistics, University of Washington Autumn 2016 1 / 31 Creating New Variables Here we create new variables using

More information

Extending Ninox with NX

Extending Ninox with NX Introduction Extending Ninox with NX NX, the Ninox query language, is a powerful programming language which allows you to quickly extend Ninox databases with calculations and trigger actions. While Ninox

More information

The FORMAT procedure - more than just a VALUE statement Lawrence Heaton-Wright, Quintiles, Bracknell, UK

The FORMAT procedure - more than just a VALUE statement Lawrence Heaton-Wright, Quintiles, Bracknell, UK Paper TT10 The FORMAT procedure - more than just a VALUE statement Lawrence Heaton-Wright, Quintiles, Bracknell, UK ABSTRACT The FORMAT procedure is most frequently used to define formats for variables.

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

How to Read, Write, and Manipulate SAS Dates

How to Read, Write, and Manipulate SAS Dates Paper HW-063 How to Read, Write, and Manipulate SAS Dates Jenine Milum, Charlotte, NC ABSTRACT No matter how long you ve been programming in SAS, using and manipulating dates still seems to require effort.

More information

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 3 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA

More information

GIFT Department of Computing Science. [Spring 2016] CS-217: Database Systems. Lab-3 Manual. Single Row Functions in SQL

GIFT Department of Computing Science. [Spring 2016] CS-217: Database Systems. Lab-3 Manual. Single Row Functions in SQL GIFT Department of Computing Science [Spring 2016] CS-217: Database Systems Lab-3 Manual Single Row Functions in SQL V3.0 4/26/2016 Introduction to Lab-3 Functions make the basic query block more powerful,

More information

44 Tricks with the 4mat Procedure

44 Tricks with the 4mat Procedure 44 Tricks with the 4mat Procedure Ben Cochran, The Bedford Group, Raleigh, NC Abstract: Actually, there probably are not a total of 44 tricks that one can do with the FORMAT procedure. The number was chosen

More information

Chapter 2 Ratios, Percents, Simple Equations, and Ratio-Proportion

Chapter 2 Ratios, Percents, Simple Equations, and Ratio-Proportion Chapter 2 Ratios, Percents, Simple Equations, and Ratio-Proportion PROBLEM Decimal Fraction Percent Ratio 1. 0.05 2. 3. 45% 4. 1. Complete row 1 in the table above., 5%, 1:20 DIF: Application REF: Ratios

More information

Unit 6. Scalar Functions

Unit 6. Scalar Functions Unit 6. Scalar Functions What This Unit Is About This unit provides information on how to use various common scalar functions. What You Should Be Able to Do After completing this unit, you should be able

More information

libname learn "C:\sas\STAT6250\Examples"; /*Identifies library of data*/

libname learn C:\sas\STAT6250\Examples; /*Identifies library of data*/ CHAPTER 7 libname learn "C:\sas\STAT6250\Examples"; /*Identifies library of data*/ /*Problem 7.2*/ proc print data=learn.hosp; where Subject eq 5 or Subject eq 100 or Subject eq 150 or Subject eq 200;

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

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

Stat 302 Statistical Software and Its Applications SAS Functions

Stat 302 Statistical Software and Its Applications SAS Functions 1 Stat 302 Statistical Software and Its Applications SAS Functions Fritz Scholz Department of Statistics, University of Washington Winter Quarter 2015 February 14, 2015 2 Creating New Variables Here we

More information

Conditional Formatting

Conditional Formatting Microsoft Excel 2013: Part 5 Conditional Formatting, Viewing, Sorting, Filtering Data, Tables and Creating Custom Lists Conditional Formatting This command can give you a visual analysis of your raw data

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

Using SAS with Oracle : Writing efficient and accurate SQL Tasha Chapman and Lori Carleton, Oregon Department of Consumer and Business Services

Using SAS with Oracle : Writing efficient and accurate SQL Tasha Chapman and Lori Carleton, Oregon Department of Consumer and Business Services Using SAS with Oracle : Writing efficient and accurate SQL Tasha Chapman and Lori Carleton, Oregon Department of Consumer and Business Services When using SAS to extract data from a live Oracle database,

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

IT 374 C# and Applications/ IT695 C# Data Structures

IT 374 C# and Applications/ IT695 C# Data Structures IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation

More information

proc print data=account; <insert statement here> run;

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

Do We Know How to Function?

Do We Know How to Function? Do We Know How to Function? Janet E. Stuelpner, ASG, Inc., Cary, North Carolina ABSTRACT How do we function in SAS? There are many functions that can make programming easy and efficient. This paper will

More information

Language Reference Manual

Language Reference Manual TAPE: A File Handling Language Language Reference Manual Tianhua Fang (tf2377) Alexander Sato (as4628) Priscilla Wang (pyw2102) Edwin Chan (cc3919) Programming Languages and Translators COMSW 4115 Fall

More information

Chapter 3: Working With Your Data

Chapter 3: Working With Your Data Chapter 3: Working With Your Data Creating variables based on other variables is easily done within the data step. Assignment is carried out with the = sign. Example: INPUT var1 var2 var3; mysum = var1

More information

SCSUG Paper THE SECRET TO SAS DATES. Alison Little, MPP Texas Health and Human Services Commission

SCSUG Paper THE SECRET TO SAS DATES. Alison Little, MPP Texas Health and Human Services Commission SCSUG Paper THE SECRET TO SAS DATES Alison Little, MPP Texas Health and Human Services Commission ABSTRACT How do you know whether the field you are working with which is called birth date or procedure

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

Payflow Implementer's Guide FAQs

Payflow Implementer's Guide FAQs Payflow Implementer's Guide FAQs FS-PF-FAQ-UG-201702--R016.00 Fairsail 2017. All rights reserved. This document contains information proprietary to Fairsail and may not be reproduced, disclosed, or used

More information

Today s Experts. Mastering Dates Using SEQUEL 1. Technical Consultant. Technical Consultant

Today s Experts. Mastering Dates Using SEQUEL 1. Technical Consultant. Technical Consultant Today s Experts Steven Spieler Vivian Hall Technical Consultant Technical Consultant Mastering Dates Using SEQUEL 1 Mastering Dates Using SEQUEL Mastering Dates Using SEQUEL 2 Working with dates on the

More information

Neil Howard, Mel. Discovering the FUN in SAS Functions. Breaking Down a Function - Arguments. Abstract and Definition

Neil Howard, Mel. Discovering the FUN in SAS Functions. Breaking Down a Function - Arguments. Abstract and Definition Discovering the FUN in SAS Functions Neil Howard, Mel Abstract and Definition A FUNCTION returns a value from a computation or system manipulation. Like most programming languages, SAS Software provides

More information

From An Introduction to SAS University Edition. Full book available for purchase here.

From An Introduction to SAS University Edition. Full book available for purchase here. From An Introduction to SAS University Edition. Full book available for purchase here. Contents List of Programs... xi About This Book... xvii About the Author... xxi Acknowledgments... xxiii Part 1: Getting

More information

Formative Benchmark 1

Formative Benchmark 1 Key Tested Formative Benchmark 1 November 213-20, 2013 Section 1: Lessons 1-10 Number Sentences, Show Data through Graphs, Repeating Patterns with Colors, Shapes and Letters Section 2: Lessons 11-20 Fractions

More information

Effectively Utilizing Loops and Arrays in the DATA Step

Effectively Utilizing Loops and Arrays in the DATA Step Paper 1618-2014 Effectively Utilizing Loops and Arrays in the DATA Step Arthur Li, City of Hope National Medical Center, Duarte, CA ABSTRACT The implicit loop refers to the DATA step repetitively reading

More information

This is the Modern World: Simple, Overlooked SAS Enhancements

This is the Modern World: Simple, Overlooked SAS Enhancements Paper AD18 This is the Modern World: Simple, Overlooked SAS Enhancements Bruce Gilsen, Federal Reserve Board, Washington, DC INTRODUCTION At my job as a SAS consultant at the Federal Reserve Board, reading

More information

Microsoft Excel 2010 Handout

Microsoft Excel 2010 Handout Microsoft Excel 2010 Handout Excel is an electronic spreadsheet program you can use to enter and organize data, and perform a wide variety of number crunching tasks. Excel helps you organize and track

More information

ADVANCED ALGORITHMS TABLE OF CONTENTS

ADVANCED ALGORITHMS TABLE OF CONTENTS ADVANCED ALGORITHMS TABLE OF CONTENTS ADVANCED ALGORITHMS TABLE OF CONTENTS...1 SOLVING A LARGE PROBLEM BY SPLITTING IT INTO SEVERAL SMALLER SUB-PROBLEMS CASE STUDY: THE DOOMSDAY ALGORITHM... INTRODUCTION

More information

The data step allows for creation, assembly and modification of SAS data sets.

The data step allows for creation, assembly and modification of SAS data sets. The data step allows for creation, assembly and modification of SAS data sets. Sources of information include existing SAS data sets, database files, spreadsheets and other raw data files. Like a procedure,

More information

Tips & Tricks. With lots of help from other SUG and SUGI presenters. SAS HUG Meeting, November 18, 2010

Tips & Tricks. With lots of help from other SUG and SUGI presenters. SAS HUG Meeting, November 18, 2010 Tips & Tricks With lots of help from other SUG and SUGI presenters 1 SAS HUG Meeting, November 18, 2010 2 3 Sorting Threads Multi-threading available if your computer has more than one processor (CPU)

More information

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All rights reserved. Java application A computer program that executes when you use the java command to launch the Java Virtual Machine

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Why Jan 1, 1960? See:

Why Jan 1, 1960? See: 1 Why Jan 1, 1960? See: http://support.sas.com/community/newsletters/news/insider/dates.html Tony Barr was looking for a timestamp that would pre-date most electronic records that were available in the

More information

22/10/16. Data Coding in SPSS. Data Coding in SPSS. Data Coding in SPSS. Data Coding in SPSS

22/10/16. Data Coding in SPSS. Data Coding in SPSS. Data Coding in SPSS. Data Coding in SPSS DATA CODING IN SPSS STAFF TRAINING WORKSHOP March 28, 2017 Delivered by Dr. Director of Applied Economics Unit African Heritage Institution Enugu Nigeria To code data in SPSS, Lunch the SPSS The Data Editor

More information

5 th Grade Mathematics - SFAW Focus MONTH CONTENT/THEME CORE GOALS/SKILLS ASSESSMENT SUGGESTED RESOURCES

5 th Grade Mathematics - SFAW Focus MONTH CONTENT/THEME CORE GOALS/SKILLS ASSESSMENT SUGGESTED RESOURCES MONTH CONTENT/THEME CORE GOALS/SKILLS ASSESSMENT SUGGESTED RESOURCES 1 st Trimester September/ October NUMBER SENSE. PROPERTIES, AND OPERATIONS Read, write, compare and order whole numbers to 1,000,000

More information

Microsoft Excel 2013 Series and Custom Lists (Level 3)

Microsoft Excel 2013 Series and Custom Lists (Level 3) IT Training Microsoft Excel 2013 Series and Custom Lists (Level 3) Contents Introduction...1 Extending a Single Cell...1 Built-in Data Series...2 Extending Two Cells...2 Extending Multiple Cells...3 Linear

More information

Example. Section: PS 709 Examples of Calculations of Reduced Hours of Work Last Revised: February 2017 Last Reviewed: February 2017 Next Review:

Example. Section: PS 709 Examples of Calculations of Reduced Hours of Work Last Revised: February 2017 Last Reviewed: February 2017 Next Review: Following are three examples of calculations for MCP employees (undefined hours of work) and three examples for MCP office employees. Examples use the data from the table below. For your calculations use

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

Do not turn to the next page until the start of the exam.

Do not turn to the next page until the start of the exam. Introduction to Programming, PIC10A E. Ryu Fall 2017 Midterm Exam Friday, November 3, 2017 50 minutes, 11 questions, 100 points, 8 pages While we don t expect you will need more space than provided, you

More information

MIT AITI Python Software Development

MIT AITI Python Software Development MIT AITI Python Software Development PYTHON L02: In this lab we practice all that we have learned on variables (lack of types), naming conventions, numeric types and coercion, strings, booleans, operator

More information

CS 115 Data Types and Arithmetic; Testing. Taken from notes by Dr. Neil Moore

CS 115 Data Types and Arithmetic; Testing. Taken from notes by Dr. Neil Moore CS 115 Data Types and Arithmetic; Testing Taken from notes by Dr. Neil Moore Statements A statement is the smallest unit of code that can be executed on its own. So far we ve seen simple statements: Assignment:

More information

B/ Use data set ADMITS to find the most common day of the week for admission. (HINT: Use a function or format.)

B/ Use data set ADMITS to find the most common day of the week for admission. (HINT: Use a function or format.) ASSIGNMENT #6 (*** ANSWERS ***) #1 DATES The following data are similar to data in example 8.3 in the notes. data admits format admit mmddyy10. input admit1 : mmddyy10. @@ datalines 11181998 12111998 02281998

More information

Imelda C. Go, South Carolina Department of Education, Columbia, SC

Imelda C. Go, South Carolina Department of Education, Columbia, SC PO 082 Rounding in SAS : Preventing Numeric Representation Problems Imelda C. Go, South Carolina Department of Education, Columbia, SC ABSTRACT As SAS programmers, we come from a variety of backgrounds.

More information

Remember to always check your simple SAS function code! Yingqiu Yvette Liu, Merck & Co. Inc., North Wales, PA

Remember to always check your simple SAS function code! Yingqiu Yvette Liu, Merck & Co. Inc., North Wales, PA PharmaSUG 2016 - Paper QT24 Remember to always check your simple SAS function code! Yingqiu Yvette Liu, Merck & Co. Inc., North Wales, PA ABSTRACT In our daily programming work we may not get expected

More information

INFORMATION TECHNOLOGY SPREADSHEETS. Part 1

INFORMATION TECHNOLOGY SPREADSHEETS. Part 1 INFORMATION TECHNOLOGY SPREADSHEETS Part 1 Page: 1 Created by John Martin Exercise Built-In Lists 1. Start Excel Spreadsheet 2. In cell B1 enter Mon 3. In cell C1 enter Tue 4. Select cell C1 5. At the

More information

CS Programming I: Arrays

CS Programming I: Arrays CS 200 - Programming I: Arrays Marc Renault Department of Computer Sciences University of Wisconsin Madison Fall 2017 TopHat Sec 3 (PM) Join Code: 719946 TopHat Sec 4 (AM) Join Code: 891624 Array Basics

More information

Contents. Generating data with DO loops Processing variables with arrays

Contents. Generating data with DO loops Processing variables with arrays Do-to & Array Contents Generating data with DO loops Processing variables with arrays 2 Generating Data with DO Loops Contents Introduction Constructing DO loops Do loop execution Counting do loop iterations

More information

Information Science 1

Information Science 1 Topics covered Information Science 1 Terms and concepts from Week 8 Simple calculations Documenting programs Simple Calcula,ons Expressions Arithmetic operators and arithmetic operator precedence Mixed-type

More information

Nortel Enterprise Reporting Quality Monitoring Meta-Model Guide

Nortel Enterprise Reporting Quality Monitoring Meta-Model Guide NN44480-110 Nortel Enterprise Reporting Quality Monitoring Meta-Model Guide Product release 6.5 and 7.0 Standard 01.03 November 2009 Nortel Enterprise Reporting Quality Monitoring Meta-Model Guide Publication

More information

CS 115 Lecture 4. More Python; testing software. Neil Moore

CS 115 Lecture 4. More Python; testing software. Neil Moore CS 115 Lecture 4 More Python; testing software Neil Moore Department of Computer Science University of Kentucky Lexington, Kentucky 40506 neil@cs.uky.edu 8 September 2015 Syntax: Statements A statement

More information

Excel Tips. Contents. By Dick Evans

Excel Tips. Contents. By Dick Evans Excel Tips By Dick Evans Contents Pasting Data into an Excel Worksheet... 2 Divide by Zero Errors... 2 Creating a Dropdown List... 2 Using the Built In Dropdown List... 3 Entering Data with Forms... 4

More information

9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C

9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C Overview The C Programming Language (with material from Dr. Bin Ren, William & Mary Computer Science) Motivation Hello, world! Basic Data Types Variables Arithmetic Operators Relational Operators Assignments

More information

DSCI 325: Handout 3 Creating and Redefining Variable in SAS Spring 2017

DSCI 325: Handout 3 Creating and Redefining Variable in SAS Spring 2017 DSCI 325: Handout 3 Creating and Redefining Variable in SAS Spring 2017 Content Source: The Little SAS Book, Chapter 3, by L. Delwiche and S. Slaughter. CREATING NEW VARIABLES OR REDEFINING VARIABLES In

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

C++ PROGRAMMING. For Industrial And Electrical Engineering Instructor: Ruba A. Salamh

C++ PROGRAMMING. For Industrial And Electrical Engineering Instructor: Ruba A. Salamh C++ PROGRAMMING For Industrial And Electrical Engineering Instructor: Ruba A. Salamh CHAPTER TWO: Fundamental Data Types Chapter Goals In this chapter, you will learn how to work with numbers and text,

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

The C Programming Language. (with material from Dr. Bin Ren, William & Mary Computer Science)

The C Programming Language. (with material from Dr. Bin Ren, William & Mary Computer Science) The C Programming Language (with material from Dr. Bin Ren, William & Mary Computer Science) 1 Overview Motivation Hello, world! Basic Data Types Variables Arithmetic Operators Relational Operators Assignments

More information

Introduction to Functions and Variables

Introduction to Functions and Variables Introduction to Functions and Variables Functions are a way to add additional elements into your OBI Report. They enable you to manipulate data, perform computations and comparisons, and get system information.

More information

Values & Variables 1

Values & Variables 1 Values & Variables 1 Properties of variables Should have a type Stores data Case sensitive Their names can not start with a number Reserved keywords can not be used as variable names 2 Keywords 3 How to

More information

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Contents 1 Introduction...2 2 Lexical Conventions...2 3 Types...3 4 Syntax...3 5 Expressions...4 6 Declarations...8 7 Statements...9

More information

Unit 3 Fill Series, Functions, Sorting

Unit 3 Fill Series, Functions, Sorting Unit 3 Fill Series, Functions, Sorting Fill enter repetitive values or formulas in an indicated direction Using the Fill command is much faster than using copy and paste you can do entire operation in

More information

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments. Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started

More information

Unit 3 Functions Review, Fill Series, Sorting, Merge & Center

Unit 3 Functions Review, Fill Series, Sorting, Merge & Center Unit 3 Functions Review, Fill Series, Sorting, Merge & Center Function built-in formula that performs simple or complex calculations automatically names a function instead of using operators (+, -, *,

More information

Adding records Pasting records Deleting records Sorting records Filtering records Inserting and deleting columns Calculated columns Working with the

Adding records Pasting records Deleting records Sorting records Filtering records Inserting and deleting columns Calculated columns Working with the Show All About spreadsheets You can use a spreadsheet to enter and calculate data. A spreadsheet consists of columns and rows of cells. You can enter data directly into the cells of the spreadsheet and

More information

Organizing and Summarizing Data

Organizing and Summarizing Data 1 Organizing and Summarizing Data Key Definitions Frequency Distribution: This lists each category of data and how often they occur. : The percent of observations within the one of the categories. This

More information

DATA Step Debugger APPENDIX 3

DATA Step Debugger APPENDIX 3 1193 APPENDIX 3 DATA Step Debugger Introduction 1194 Definition: What is Debugging? 1194 Definition: The DATA Step Debugger 1194 Basic Usage 1195 How a Debugger Session Works 1195 Using the Windows 1195

More information

Visual C# Instructor s Manual Table of Contents

Visual C# Instructor s Manual Table of Contents Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms

More information

Sinusoidal Data Worksheet

Sinusoidal Data Worksheet Sinusoidal Data Worksheet West Coast Tidal Analysis: Fill in the following chart for the low tide and high tides per day for the researched two-day period (so four low tides and high tides all inter-distributed)

More information

Conversion Functions

Conversion Functions Conversion Functions Data type conversion Implicit data type conversion Explicit data type conversion 3-1 Implicit Data Type Conversion For assignments, the Oracle server can automatically convert the

More information

Outline. Data and Operations. Data Types. Integral Types

Outline. Data and Operations. Data Types. Integral Types Outline Data and Operations Data Types Arithmetic Operations Strings Variables Declaration Statements Named Constant Assignment Statements Intrinsic (Built-in) Functions Data and Operations Data and Operations

More information

More on variables and methods

More on variables and methods More on variables and methods Robots Learning to Program with Java Byron Weber Becker chapter 7 Announcements (Oct 12) Reading for Monday Ch 7.4-7.5 Program#5 out Character Data String is a java class

More information

SPRINGBOARD UNIT 6 DATA ANALYSIS AND PROBABILITY

SPRINGBOARD UNIT 6 DATA ANALYSIS AND PROBABILITY SPRINGBOARD UNIT 6 DATA ANALYSIS AND PROBABILITY 6. Theoretical and Experimental Probability Probability = number of ways to get outcome number of possible outcomes Theoretical Probability the probability

More information