sas functions old and new -...

Post on 06-Mar-2018

236 Views

Category:

Documents

12 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

SAS Functions Old and NewRandy Betancourt

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

Types of Functions OVERVIEW

Character Numeric Date and Time Macro State and Zip Code Special SAS Data set I/O External File I/O Variable Information

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

Changes and Enhancements OVERVIEW

In Release 9.2• Added 40+ new functions. • TRANSTRN removes or replaces all occurrences of a

substring in a character string Moved numerous SAS/ETS and Risk Dimensions functions into

Base SAS• INTFMT returns a recommended format, given a date, time,

or datetime interval Moved High Performance Forecasting functions into Base SAS

• HOLIDAY returns the date of the specified holiday for the specified year

Enhancements to numerous functions and CALL Routines

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

Changes and Enhancements OVERVIEW

In Release 9.3• Added new functions • MVALID checks the validity of a character string for use as

a SAS member name Enhancements to existing functions and CALL Routines SAS Documentation Change

• The SAS Language Reference: Dictionary is divided into 7 documents

• SAS Functions and CALL Routines: Reference

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

Length Assignment Rules Character Strings

Character variable lengths are set at Compile-time Context determines how lengths are set: Explicitly

INFORMATS on INFILE/INPUT LENGTH statement ATTRIB statement DBSTYPE= data set option (SAS/Access)

Implicitly On initial assignment Metadata exchange, e.g. default mappings with

SAS/Access

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

Comparisons Character Strings

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

Comparisons Character Strings

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

LENGTH & LENGTHC Character Strings

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

ANYxxx and NOTxxxFunctions Character Strings

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

SUBSTR and INPUT Functions Character Strings

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

SUBSTR (left of =) and PUT Functions Character Strings

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

CAT, CATS, and CATX Functions Character Strings

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

PUT and INPUT Functions Character Strings

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

SAS Macro Functions Character Strings

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

PERL Regular Expressions Character Strings

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

PROC FCMP User-defined Functions

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

SAS Date Time Processing

SAS Date values represent the number of days between January 1, 1960 and a specified date.

SAS Time values represent the number of seconds since midnight of the current day. SAS time values are between 0 and 86400.

SAS Datetime values represent the number of seconds between January 1, 1960 and an hour/minute/second within a specified date and time.

These values are stored as numbers and can be read with SAS informats and displayed with SAS formats

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

Date Informats SAS Date Processing

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

YEARCUTOFF Behavior SAS Date Processing

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

MDY, MONTH, DAY Functions SAS Date Processing

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

INTCK and TODAY Functions SAS Date Processing

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

INTNX Function SAS Date Processing for Finding First and Last of Month

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

INTNX Function SAS Date Processing for Finding First and Last of Month (Business Week)

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

INTNX Function Finding First and Last of Month for Business Week to Build a Format

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

PROC FMTLIB Validating Formats

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

INTNX Function Finding First and Last of Month for Business Week to Build a Format

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

Best Practices Ensuring Date Integrity

Store dates as SAS date values, not as simple numeric or characters

Explicitly set YEARCUTOFF= when using 2-digit SAS date values

2-digit years spanning more than 100 years must either use 4-digit years in the data, or handled with conditional logic

Ensure output data sets represent dates as SAS date values

Examine output closely to ensure formats and informatsare producing the intended results

Copyr igh t © 2012, SAS Ins t i tu te Inc . A l l r igh ts reserved.

An Introduction to SAS Character Functions (Including New SAS Functions), by Ron Cody

SAS Functions Old and New, by Ron Coleman, Internal SAS Presentation

SAS Date/Time Processing, by Cynthia Johnson, Internal SAS Presentation

SAS 9.3 Functions and CALL Routines: Reference at: support.sas.com

References

top related