SAS coding for those who like to be control

Size: px
Start display at page:

Download "SAS coding for those who like to be control"

Transcription

1 SAS coding for those who like to be control Montreal SAS Users Group 30 May 2018 Charu Shankar SAS Institute, Toronto

2 About your presenter SAS Senior Technical Training Specialist, Charu Shankar teaches by engaging with logic, visuals and analogies to spark critical thinking. She interviews clients to recommend the right SAS training. She is a frequent blogger for the SAS Training Post. When she s not teaching technology, she is passionate about helping people come alive with yoga and is a food blogger. Charu has presented at over 100 SAS international user group conferences on topics related to SAS programming, SQL, DS2 programming, tips and tricks with coding, new features of SAS and SAS Enterprise Guide.

3

4 AGENDA 1. The dataset controller 2. The observation controller 3. The function controller 4. The format controller 5. The PROC controller 6. The Macro controller 7. The SQL controller 8. Questions 9. Handy Links

5 Providing high quality SAS training since THE DATASET CONTROLLER

6 1. THE DATASET CONTROLLER Business Scenario create 3 new data sets based on country value. Added complexity-not too happy with SQL, needs 3 reads must do everything in 1 read of the table. orion.employee_addresses usa other Country='US' australia Country='AU'

7 1. THE DATASET CONTROLLER Creating Multiple SAS Data Sets List names of output data sets in the DATA statement. DATA <SAS-data-set-1 SAS-data-set-n>; data usa australia other; set monsug2.employee_addresses; if Country='AU' then output australia; else if Country='US' then output usa; else output other; run; You can direct output to a specific data set or data sets by listing the data set names in the OUTPUT statement. p202d03

8 1. THE DATASET CONTROLLER Check the SAS Log Three data sets were created. The log shows that US was the most frequently occurring value. Partial SAS Log NOTE: There were 424 observations read from the data set MONSUG2.EMPLOYEE_ADDRESSES. NOTE: The data set WORK.USA has 311 observations and 9 variables. NOTE: The data set WORK.AUSTRALIA has 105 observations and 9 variables. NOTE: The data set WORK.OTHER has 8 observations and 9 variables. 8

9 1. THE DATASET CONTROLLER Get control with PROC FREQ proc freq data=monsug2.employee_addresses order=freq; tables country; run; 9

10 Providing high quality SAS training since THE OBSERVATION CONTROLLER

11 2. THE OBSERVATION CONTROLLER Business Scenario forecast growth rate of 6 departments for a 2-year period. Current Employee Count Total_ Department Employees Increase Administration Engineering IS Marketing Sales Sales Management Total_ Department Employees Increase Year Predicted Two-Year Growth Rate Administration Administration Engineering Engineering IS IS

12 2. THE OBSERVATION CONTROLLER Explicit Output The explicit OUTPUT statement writes contents of the program data vector (PDV) to the output data set or data sets. The explicit OUTPUT statement overrides implicit output. data forecast; set monsug2.growth; Year=1; 1 2 run; Total_Employees=Total_Employees*(1+Increase); output; OUTPUT <SAS-data-set-1 SAS-data-set-n>; Year=2; Total_Employees=Total_Employees*(1+Increase); output; No implicit OUTPUT; Implicit RETURN; p202d01

13 2. THE OBSERVATION CONTROLLER Partial SAS Log NOTE: There were 6 observations read from the data set MONSUG2.GROWTH. NOTE: The data set WORK.FORECAST has 12 observations and 4 variables. Partial PROC PRINT Output Total_ Department Employees Year Administration Administration Engineering Engineering IS IS Marketing Marketing Copyright SAS Institute Inc. All rights reserved. 2 13

14 Providing high quality SAS training since THE FUNCTION CONTROLLER

15 3. THE FUNCTION CONTROLLER Business Scenario Complete the assignment statement to correctly extract 2007 from the Text variable data Scan_Quiz; Text="New Year's Day, January 1st, 2007"; Year=? ; run; a. scan(text,6); b. scan(text,6,', '); c. All of the above would work. d. Is there a 4th better way? p205d05

16 3. THE FUNCTION CONTROLLER SCAN Function: Details When you use the SCAN function: A missing value is returned if there are fewer than n words in the string. If n is negative, the SCAN function selects the word in the character string starting from the end of string. NewVar=SCAN(string,n<,charlist>); The SCAN function returns the nth word of a character value.

17 4. THE FORMAT CONTROLLER

18 4. THE FORMAT CONTROLLER Business Scenario Management has requested using country names, instead of country codes, in reports. Country Population Country_ID AU 20,000, CA. 260 DE 80,000, IL 5,000, Country Population Country_ID Australia 20,000, Canada. 260 Germany 80,000, Israel 5,000,

19 4. THE FORMAT CONTROLLER Creating a Format (the manual way) Use PROC FORMAT to create the format. proc format; value $country 'AU' = 'Australia' 'CA' = 'Canada' 'DE' = 'Germany' 'IL' = 'Israel' 'TR' = 'Turkey' 'US' = 'United States' 'ZA' = 'South Africa'; run;

20 4. THE FORMAT CONTROLLER Using a Control Data Set to Create a Format Instead of entering all of the values in PROC FORMAT, you can create a format from a SAS data set that contains the code and value information. Partial Listing of orion.country Country AU Country_Name Australia Control data set CA DE IL TR Canada Germany Israel Turkey Partial Listing of country Start Label FmtName AU Australi a $country CA Canada $country PROC FORMAT $country DE German y $country IL Israel $country TR Turkey $country

21 4. THE FORMAT CONTROLLER Using a Control Data Set to Create a Format Partial orion.country Country Country_ Country_ Population Country_ID Continent_ID Name FormerName AU Australia 20,000, CA Canada DE Germany 80,000, East/West Germany IL Israel 5,000, DATA Step Start Label FmtName data country; keep Start Label FmtName; retain FmtName '$country'; set monsug1.country(rename=(country=start Country_Name=Label)); run;

22 4. THE FORMAT CONTROLLER Using a Control Data Set to Create a Format Use the CNTLIN= option to read the data and create the format. proc format cntlin=country; run; CNTLIN=SAS-data-set The variables FmtName, Start, and Label are required in order to create a format from a CNTLIN data set.

23 4. THE FORMAT CONTROLLER Where Formats Are Stored By default, formats are stored in the work.formats catalog and exist only for the duration of the SAS session. PROC FORMAT; work.formats

24 4. THE FORMAT CONTROLLER Using the LIBRARY= Option Use the LIBRARY= option to control where the format is stored. proc format library=monsug1.myfmts cntlin=country; run; LIBRARY=libref.catalog

25 5. THE PROC CONTROLLER Business Scenario Providing high quality SAS training since 1972 summer construction plan in the city of Montreal included an upside down Pylon in every pothole. But mistakes happen.. Some neighbourhoods have multiple pylons. While you have to admit.. They make a style statement. But The city wants your help in identifying duplicates.

26 5. THE PROC CONTROLLER Providing high quality SAS training since 1972

27 5. THE PROC CONTROLLER Report 1 Providing high quality SAS training since 1972 libname pylon pcfiles path= 'c:\monsug 2018\montroyal pylons.xlsx'; proc freq data=pylon.'mondieu$'n order=data; tables quartier; run;

28 5. THE PROC CONTROLLER Report 2 Providing high quality SAS training since 1972 proc freq data=pylon.'mondieu$'n order=freq; tables quartier; run;

29 5. THE PROC CONTROLLER Report 3 Providing high quality SAS training since 1972 proc freq data=pylon.'mondieu$'n noprint; tables quartier/out=dups(where=(count >1)) nocum nopercent; run;

30 Providing high quality SAS training since THE MACRO CONTROLLER Who is really in charge :)

31 Providing high quality SAS training since THE MACRO CONTROLLER Business Scenario List all royal couples who dated under 2 years as of today. Place today's date on the title so we know this is the most modern & upto date data :)

32 Providing high quality SAS training since THE MACRO CONTROLLER title "royal couples who dated for <2 years as of today() we shall never know"; title2 "royal couples who dated for <2 years as of %sysfunc(today(), date.)"; proc print data=royal.'marriages$'n noobs; var name title meetingplace yearsdated; where yearsdated <=2; run;

33 6. THE MACRO CONTROLLER Macro Functions %SYSFUNC is a powerful macro function that can be used to execute data step functions. %SYSFUNC (function(argument-1 <...argument-n>)<, format> ); %SYSFUNC (TODAY(), weekdate.);

34 7. THE SQL CONTROLLER Providing high quality SAS training since 1972

35 7. THE SQL CONTROLLER Business Scenario List all employees in the Sales Department with salaries above the department average. Include the average salary for the department in the report title. Sales Department Employees Earning More than the Department Average of Row Employee_ID Salary ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

36 7. THE SQL CONTROLLER Creating Macro Variables: Syntax 1 Syntax 1 places values from the first row returned by an SQL query into one or more macro variables. Data from additional rows returned by the query is ignored. SELECT column-1 format=format-name. <, column-n> INTO :macvar_1<,... :macvar_n> FROM table view The value from the first column in the SELECT clause is placed in the first macro variable listed in the INTO clause, and so on.

37 7. THE SQL CONTROLLER Creating One Macro Variable: Syntax 1 Step 1 store average Sales Department salary in macro variable. %let Dept=Sales; proc sql noprint; select avg(salary) into :MeanSalary from monsug2.employee_payroll as p, monsug2.employee_organization as o where p.employee_id=o.employee_id and Department=propcase("&Dept"); quit; s108d06

38 7. THE SQL CONTROLLER Step 2 Use stored macro variable List employees in the Sales Department with salaries greater than the average. Include average salary in title. reset print number; title "&Dept Department Employees Earning"; title2 "More than the Department Average " "of &MeanSalary"; select p.employee_id, Salary from monsug2.employee_payroll as p, monsug2.employee_organization as o where p.employee_id=o.employee_id and Department=Propcase("&Dept") and Salary > &MeanSalary; quit; s108d06

39 7. THE SQL CONTROLLER Sales Department Employees Earning More than the Department Average of Row Employee_ID Salary ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

40 6. HANDY LINKS SAS programmer Rule #1 PROC SQL query INTO a macro variable Creating a format from a Control Dataset Explicit OUTPUT statement in the Data step SCAN function returns Nth word from character string %SYSFUNC macro variable supports sas functions in the other parts of sas code

41 Thank you Charu Shankar SAS Institute Toronto Blog Twitter CharuYogaCan Linkedin

Top 5 Handy PROC SQL Tips You Didn t Think Were Possible

Top 5 Handy PROC SQL Tips You Didn t Think Were Possible Top 5 Handy PROC SQL Tips You Didn t Think Were Possible Montreal SAS users Group 30 May 2018 11:00-11:40 Charu Shankar SAS Institute, Toronto About your presenter SAS Senior Technical Training Specialist,

More information

INVESTIGATE YOUR DATA 4 POWERFUL SAS LANGUAGES

INVESTIGATE YOUR DATA 4 POWERFUL SAS LANGUAGES INVESTIGATE YOUR DATA 4 POWERFUL SAS LANGUAGES Vancouver SAS Users Group Vancouver, British Columbia 26 November 2014 Charu Shankar Technical Training Specialist SAS Institute Inc. Canada SITUATION Crime

More information

BAKING OR COOKING LEARN THE DIFFERENCE BETWEEN SAS ARRAYS AND HASH OBJECTS

BAKING OR COOKING LEARN THE DIFFERENCE BETWEEN SAS ARRAYS AND HASH OBJECTS BAKING OR COOKING LEARN THE IFFERENCE BETWEEN SAS ARRAYS AN HASH OBJECTS WISCONSIN ILLINOIS SAS USERS GROUP MILWAUKEE 29 JUNE 2016 CHARU SHANKAR SAS INSTITUTE INC. Copyright 2013, SAS Institute Inc. All

More information

INTRODUCTION TO PROC SQL JEFF SIMPSON SYSTEMS ENGINEER

INTRODUCTION TO PROC SQL JEFF SIMPSON SYSTEMS ENGINEER INTRODUCTION TO PROC SQL JEFF SIMPSON SYSTEMS ENGINEER THE SQL PROCEDURE The SQL procedure: enables the use of SQL in SAS is part of Base SAS software follows American National Standards Institute (ANSI)

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

Know Thy Data : Techniques for Data Exploration

Know Thy Data : Techniques for Data Exploration Know Thy Data : Techniques for Data Exploration Montreal SAS Users Group Wednesday, 29 May 2018 13:50-14:30 PM Andrew T. Kuligowski, Charu Shankar AGENDA Part 1- Easy Ways to know your data Part 2 - Powerful

More information

ACHOO - THE FLU, SAS & YOU

ACHOO - THE FLU, SAS & YOU ACHOO - THE FLU, SAS & YOU CHARU SHANKAR, SAS INSTITUTE CANADA Health User Group Toronto 20 November 2015 AGENDA ACHOO - THE FLU, SAS & YOU 1. Some like it cold -Ways to fight the flu 2. Data Collection

More information

Retrieving Data from Multiple Tables

Retrieving Data from Multiple Tables Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Database Lab (ECOM 4113) Lab 5 Retrieving Data from Multiple Tables Eng. Mohammed Alokshiya November 2, 2014 An JOIN clause

More information

11. Reading SAS datasets. GIORGIO RUSSOLILLO - Cours de prépara)on à la cer)fica)on SAS «Base Programming» 242

11. Reading SAS datasets. GIORGIO RUSSOLILLO - Cours de prépara)on à la cer)fica)on SAS «Base Programming» 242 11. Reading SAS datasets 242 Reading a single SAS dataset DATA SAS-dataset; SET SAS-dataset; ; - SAS-dataset in the DATA statement is the name (libref.filename) of the dataset to be

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

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

Why choose between SAS Data Step and PROC SQL when you can have both?

Why choose between SAS Data Step and PROC SQL when you can have both? Paper QT-09 Why choose between SAS Data Step and PROC SQL when you can have both? Charu Shankar, SAS Canada ABSTRACT As a SAS coder, you've often wondered what the SQL buzz is about. Or vice versa you

More information

Conditional Processing in the SAS Software by Example

Conditional Processing in the SAS Software by Example Conditional Processing in the SAS Software by Example Charu Shankar, SAS Institute Canada, Toronto, Canada Kirk Paul Lafler, Software Intelligence Corporation, Spring Valley, California Abstract Conditional

More information

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

PASS4TEST. IT Certification Guaranteed, The Easy Way!  We offer free update service for one year PASS4TEST \ http://www.pass4test.com We offer free update service for one year Exam : A00-212 Title : SAS Advanced Programming Exam for SAS 9 Vendor : SASInstitute Version : DEMO Get Latest & Valid A00-212

More information

General Tips for Working with Large SAS datasets and Oracle tables

General Tips for Working with Large SAS datasets and Oracle tables General Tips for Working with Large SAS datasets and Oracle tables 1) Avoid duplicating Oracle tables as SAS datasets only keep the rows and columns needed for your analysis. Use keep/drop/where directly

More information

A SAS Solution to Create a Weekly Format Susan Bakken, Aimia, Plymouth, MN

A SAS Solution to Create a Weekly Format Susan Bakken, Aimia, Plymouth, MN Paper S126-2012 A SAS Solution to Create a Weekly Format Susan Bakken, Aimia, Plymouth, MN ABSTRACT As programmers, we are frequently asked to report by periods that do not necessarily correspond to weeks

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

Database Programming with PL/SQL

Database Programming with PL/SQL Database Programming with PL/SQL 5-4 Objectives This lesson covers the following objectives: List the benefits of using parameters with cursors Create PL/SQL code to declare and use a cursor with a parameter

More information

How to Create Data-Driven Lists

How to Create Data-Driven Lists Paper 9540-2016 How to Create Data-Driven Lists Kate Burnett-Isaacs, Statistics Canada ABSTRACT As SAS programmers we often want our code or program logic to be driven by the data at hand, rather than

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

Are Your SAS Programs Running You?

Are Your SAS Programs Running You? Overview Are Your SAS Programs Running You? Have you ever QUICKLY written some code assuming it will never be used again?? Is it now 5 years later and the SPAGHETTI CODE is still in production? Worse still

More information

Planting Your Rows: Using SAS Formats to Make the Generation of Zero- Filled Rows in Tables Less Thorny

Planting Your Rows: Using SAS Formats to Make the Generation of Zero- Filled Rows in Tables Less Thorny Planting Your Rows: Using SAS Formats to Make the Generation of Zero- Filled Rows in Tables Less Thorny Kathy Hardis Fraeman, United BioSource Corporation, Bethesda, MD ABSTRACT Often tables or summary

More information

Using the Set Operators. Copyright 2006, Oracle. All rights reserved.

Using the Set Operators. Copyright 2006, Oracle. All rights reserved. Using the Set Operators Objectives After completing this lesson, you should be able to do the following: Describe set operators Use a set operator to combine multiple queries into a single query Control

More information

Database Systems CSE 303. Outline. Lecture 06: SQL. What is Sub-query? Sub-query in WHERE clause Subquery

Database Systems CSE 303. Outline. Lecture 06: SQL. What is Sub-query? Sub-query in WHERE clause Subquery Database Systems CSE 303 Lecture 06: SQL 2016 Subquery Outline What is a Subquery Subquery in WHERE clause >ALL, >ANY, >=ALL,

More information

Database Management Systems,

Database Management Systems, Database Management Systems SQL Query Language (3) 1 Topics Aggregate Functions in Queries count sum max min avg Group by queries Set Operations in SQL Queries Views 2 Aggregate Functions Tables are collections

More information

Working with Big Data in SAS

Working with Big Data in SAS ABSTRACT Paper SAS2160-2018 Working with Big Data in SAS Mark L. Jordan, SAS Institute Inc. This paper demonstrates challenges and solutions when using SAS to process large data sets. Learn how to do the

More information

ABSTRACT. Paper CC-031

ABSTRACT. Paper CC-031 Paper CC-031 Using Functions SYSFUNC and IFC to Conditionally Execute Statements in Open Code Ronald J. Fehd, Centers for Disease Control and Prevention, Atlanta, GA, USA ABSTRACT Audience Keywords Information

More information

Introduction to the SAS Macro Facility

Introduction to the SAS Macro Facility Introduction to the SAS Macro Facility Uses for SAS Macros The macro language allows for programs that are dynamic capable of selfmodification. The major components of the macro language include: Macro

More information

Preserving your SAS Environment in a Non-Persistent World. A Detailed Guide to PROC PRESENV. Steven Gross, Wells Fargo, Irving, TX

Preserving your SAS Environment in a Non-Persistent World. A Detailed Guide to PROC PRESENV. Steven Gross, Wells Fargo, Irving, TX Preserving your SAS Environment in a Non-Persistent World A Detailed Guide to PROC PRESENV Steven Gross, Wells Fargo, Irving, TX ABSTRACT For Enterprise Guide users, one of the challenges often faced is

More information

Efficiently Join a SAS Data Set with External Database Tables

Efficiently Join a SAS Data Set with External Database Tables ABSTRACT Paper 2466-2018 Efficiently Join a SAS Data Set with External Database Tables Dadong Li, Michael Cantor, New York University Medical Center Joining a SAS data set with an external database is

More information

%MAKE_IT_COUNT: An Example Macro for Dynamic Table Programming Britney Gilbert, Juniper Tree Consulting, Porter, Oklahoma

%MAKE_IT_COUNT: An Example Macro for Dynamic Table Programming Britney Gilbert, Juniper Tree Consulting, Porter, Oklahoma Britney Gilbert, Juniper Tree Consulting, Porter, Oklahoma ABSTRACT Today there is more pressure on programmers to deliver summary outputs faster without sacrificing quality. By using just a few programming

More information

A Side of Hash for You To Dig Into

A Side of Hash for You To Dig Into A Side of Hash for You To Dig Into Shan Ali Rasul, Indigo Books & Music Inc, Toronto, Ontario, Canada. ABSTRACT Within the realm of Customer Relationship Management (CRM) there is always a need for segmenting

More information

Data Storage and Query Answering. Indexing and Hashing (5)

Data Storage and Query Answering. Indexing and Hashing (5) Data Storage and Query Answering Indexing and Hashing (5) Linear Hash Tables No directory. Introduction Hash function computes sequences of k bits. Take only the i last of these bits and interpret them

More information

An Efficient Method to Create Titles for Multiple Clinical Reports Using Proc Format within A Do Loop Youying Yu, PharmaNet/i3, West Chester, Ohio

An Efficient Method to Create Titles for Multiple Clinical Reports Using Proc Format within A Do Loop Youying Yu, PharmaNet/i3, West Chester, Ohio PharmaSUG 2012 - Paper CC12 An Efficient Method to Create Titles for Multiple Clinical Reports Using Proc Format within A Do Loop Youying Yu, PharmaNet/i3, West Chester, Ohio ABSTRACT Do you know how to

More information

Better Metadata Through SAS II: %SYSFUNC, PROC DATASETS, and Dictionary Tables

Better Metadata Through SAS II: %SYSFUNC, PROC DATASETS, and Dictionary Tables Paper 3458-2015 Better Metadata Through SAS II: %SYSFUNC, PROC DATASETS, and Dictionary Tables ABSTRACT Louise Hadden, Abt Associates Inc., Cambridge, MA SAS provides a wealth of resources for users to

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

Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse

Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse Ben Cochran, The Bedford Group, Raleigh, NC Abstract Often SAS users need to access data from non- SAS

More information

CS 275 Winter 2011 Problem Set 3

CS 275 Winter 2011 Problem Set 3 CS 275 Winter 2011 Problem Set 3 Run the following quires in Oracle Application Express where appropriate. Cut and paste your query for each applicable question. For short answer or multiple choice type

More information

work.test temp.test sasuser.test test

work.test temp.test sasuser.test test DSCI 325 Midterm Practice Test Spring 2017 Name: 1. Consider the following four names used to create a SAS data set: work.test temp.test sasuser.test test How many of these will be stored as permanent

More information

Reference: W3School -

Reference: W3School - Language SQL SQL Adv Reference: W3School - http://www.w3schools.com/sql/default.asp http://www.tomjewett.com/dbdesign/dbdesign.php?page=recursive.php Recursive Associations/Relationship A recursive association

More information

Are Your SAS Programs Running You? Marje Fecht, Prowerk Consulting, Cape Coral, FL Larry Stewart, SAS Institute Inc., Cary, NC

Are Your SAS Programs Running You? Marje Fecht, Prowerk Consulting, Cape Coral, FL Larry Stewart, SAS Institute Inc., Cary, NC Paper CS-044 Are Your SAS Programs Running You? Marje Fecht, Prowerk Consulting, Cape Coral, FL Larry Stewart, SAS Institute Inc., Cary, NC ABSTRACT Most programs are written on a tight schedule, using

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

Macro Magic III. SNUG Presentation (30mins)

Macro Magic III. SNUG Presentation (30mins) Macro Magic III SNUG Presentation (30mins) Overview Macro Magic Posters have been displayed at the last 2 SUGA presentations. Continue the trend Hopefully everyone will learn something new SAS Macro -

More information

Bsc (Hons) Software Engineering. Examinations for / Semester 1. Resit Examinations for BSE/15A/FT & BSE/16A/FT

Bsc (Hons) Software Engineering. Examinations for / Semester 1. Resit Examinations for BSE/15A/FT & BSE/16A/FT Bsc (Hons) Software Engineering Cohort: BSE/16B/FT Examinations for 2017-2018 / Semester 1 Resit Examinations for BSE/15A/FT & BSE/16A/FT MODULE: DATABASE APPLICATION DEVELOPMENT MODULE CODE: DBT2113C

More information

Purchase this book at

Purchase this book at Chapter 2 2 Creating Simple Stored Processes BASE SAS gives programmers the exponential ability to query and report about data from their desktops; however, this limitation means that a user can access

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

Using SAS/SCL to Create Flexible Programs... A Super-Sized Macro Ellen Michaliszyn, College of American Pathologists, Northfield, IL

Using SAS/SCL to Create Flexible Programs... A Super-Sized Macro Ellen Michaliszyn, College of American Pathologists, Northfield, IL Using SAS/SCL to Create Flexible Programs... A Super-Sized Macro Ellen Michaliszyn, College of American Pathologists, Northfield, IL ABSTRACT SAS is a powerful programming language. When you find yourself

More information

David Ghan SAS Education

David Ghan SAS Education David Ghan SAS Education 416 307-4515 David.ghan@sas.com Using SQL in SAS Victoria Area SAS User Group February 12, 2004 1. What is SQL? 2. Coding an SQL Query 3. Advanced Examples a. Creating macro variables

More information

David Beam, Systems Seminar Consultants, Inc., Madison, WI

David Beam, Systems Seminar Consultants, Inc., Madison, WI Paper 150-26 INTRODUCTION TO PROC SQL David Beam, Systems Seminar Consultants, Inc., Madison, WI ABSTRACT PROC SQL is a powerful Base SAS Procedure that combines the functionality of DATA and PROC steps

More information

Agenda. Why do we want to keep a DBA happy? Development process Requirements Good coding practice Source Control Unit Tests Continuous Integration

Agenda. Why do we want to keep a DBA happy? Development process Requirements Good coding practice Source Control Unit Tests Continuous Integration Who am I? SQL Server Developer & DBA Author on Simple Talk Co-leader of SQL South West User Group Co-organiser of SQL Saturday Exeter / Data In Devon (Apr 26/27 2019) SQLBits Committee Member Agenda Why

More information

Submitting SAS Code On The Side

Submitting SAS Code On The Side ABSTRACT PharmaSUG 2013 - Paper AD24-SAS Submitting SAS Code On The Side Rick Langston, SAS Institute Inc., Cary NC This paper explains the new DOSUBL function and how it can submit SAS code to run "on

More information

CC13 An Automatic Process to Compare Files. Simon Lin, Merck & Co., Inc., Rahway, NJ Huei-Ling Chen, Merck & Co., Inc., Rahway, NJ

CC13 An Automatic Process to Compare Files. Simon Lin, Merck & Co., Inc., Rahway, NJ Huei-Ling Chen, Merck & Co., Inc., Rahway, NJ CC13 An Automatic Process to Compare Files Simon Lin, Merck & Co., Inc., Rahway, NJ Huei-Ling Chen, Merck & Co., Inc., Rahway, NJ ABSTRACT Comparing different versions of output files is often performed

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

11G ORACLE DEVELOPERS Training Program

11G ORACLE DEVELOPERS Training Program 11G ORACLE DEVELOPERS Training Program Complete OCP Track Training Developers manage the industry's most advanced information systems and command some of the highest salaries. This credential is your first

More information

Acknowledgments xi Preface xiii About the Author xv About This Book xvii New in the Macro Language xxi

Acknowledgments xi Preface xiii About the Author xv About This Book xvii New in the Macro Language xxi Contents Part 1 Acknowledgments xi Preface xiii About the Author xv About This Book xvii New in the Macro Language xxi Macro Basics Chapter 1 Introduction 3 1.1 Macro Facility Overview 3 1.2 Terminology

More information

ABSTRACT INTRODUCTION TRICK 1: CHOOSE THE BEST METHOD TO CREATE MACRO VARIABLES

ABSTRACT INTRODUCTION TRICK 1: CHOOSE THE BEST METHOD TO CREATE MACRO VARIABLES An Efficient Method to Create a Large and Comprehensive Codebook Wen Song, ICF International, Calverton, MD Kamya Khanna, ICF International, Calverton, MD Baibai Chen, ICF International, Calverton, MD

More information

Useful Tips from my Favorite SAS Resources

Useful Tips from my Favorite SAS Resources Useful Tips from my Favorite SAS Resources Marje Fecht Senior Partner, Prowerk Consulting Copyright 2017 Prowerk Consulting 1 You need an answer QUICK! I don t want to run the whole program if the input

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 4 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA

More information

DO Loop Processing. DO Loop Processing. Objectives. Repetitive Coding. DO Loop Processing

DO Loop Processing. DO Loop Processing. Objectives. Repetitive Coding. DO Loop Processing Array Processing and Reshaping ata 7.1 O Loop Processing 7.2 SAS Array Processing 7.3 Using SAS Arrays 7.4 Minitab STACK and UNSTACK 7.5 Creating a Sample ata Set in SAS O Loop Processing 1 Objectives

More information

Using Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse

Using Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse Paper DM-01 Using Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse Abstract Ben Cochran, The Bedford Group, Raleigh, NC Often SAS users need to access

More information

Tips for Mastering Relational Databases Using SAS/ACCESS

Tips for Mastering Relational Databases Using SAS/ACCESS Tips for Mastering Relational Databases Using SAS/ACCESS SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other

More information

Contents of SAS Programming Techniques

Contents of SAS Programming Techniques Contents of SAS Programming Techniques Chapter 1 About SAS 1.1 Introduction 1.1.1 SAS modules 1.1.2 SAS module classification 1.1.3 SAS features 1.1.4 Three levels of SAS techniques 1.1.5 Chapter goal

More information

SAS Information Map Studio 2.1: Tips and Techniques

SAS Information Map Studio 2.1: Tips and Techniques SAS Information Map Studio 2.1: Tips and Techniques The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2005. SAS Information Map Studio 2.1: Tips and Techniques. Cary,

More information

Lab # 6. Using Subqueries and Set Operators. Eng. Alaa O Shama

Lab # 6. Using Subqueries and Set Operators. Eng. Alaa O Shama The Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Database Lab Lab # 6 Using Subqueries and Set Operators Eng. Alaa O Shama November, 2015 Objectives:

More information

Locking SAS Data Objects

Locking SAS Data Objects 59 CHAPTER 5 Locking SAS Data Objects Introduction 59 Audience 60 About the SAS Data Hierarchy and Locking 60 The SAS Data Hierarchy 60 How SAS Data Objects Are Accessed and Used 61 Types of Locks 62 Locking

More information

Paper DB2 table. For a simple read of a table, SQL and DATA step operate with similar efficiency.

Paper DB2 table. For a simple read of a table, SQL and DATA step operate with similar efficiency. Paper 76-28 Comparative Efficiency of SQL and Base Code When Reading from Database Tables and Existing Data Sets Steven Feder, Federal Reserve Board, Washington, D.C. ABSTRACT In this paper we compare

More information

TIPS AND TRICKS: IMPROVE EFFICIENCY TO YOUR SAS PROGRAMMING

TIPS AND TRICKS: IMPROVE EFFICIENCY TO YOUR SAS PROGRAMMING TIPS AND TRICKS: IMPROVE EFFICIENCY TO YOUR SAS PROGRAMMING Guillaume Colley, Lead Data Analyst, BCCFE Page 1 Contents Customized SAS Session Run system options as SAS starts Labels management Shortcut

More information

SAS Institute Exam A SAS Advanced Programming Version: 6.0 [ Total Questions: 184 ]

SAS Institute Exam A SAS Advanced Programming Version: 6.0 [ Total Questions: 184 ] s@lm@n SAS Institute Exam A00-212 SAS Advanced Programming Version: 6.0 [ Total Questions: 184 ] Question No : 1 The report will not successfully run and will produce an error message in the log. What

More information

LinkedIn Economic Graph Project

LinkedIn Economic Graph Project LinkedIn Economic Graph Project Understanding Trade Through International Connections In Partnership with the Ontario Ministry of International Trade FEBRUARY 8 The Economic Graph as a Tool to Advance

More information

DUE: 9. Create a query that will return the average order total for all Global Fast Foods orders from January 1, 2002, to December 21, 2002.

DUE: 9. Create a query that will return the average order total for all Global Fast Foods orders from January 1, 2002, to December 21, 2002. CIS 207 Oracle - Database Programming and SQL HOMEWORK: # 10 DUE: Run the following queries in Oracle Application Express. Paste a copy of each query Into this word document below the questions or notepad.txt

More information

Updating Data Using the MODIFY Statement and the KEY= Option

Updating Data Using the MODIFY Statement and the KEY= Option Updating Data Using the MODIFY Statement and the KEY= Option Denise J. Moorman and Deanna Warner Denise J. Moorman is a technical support analyst at SAS Institute. Her area of expertise is base SAS software.

More information

A Table Driven ODS Macro Diane E. Brown, exponential Systems, Indianapolis, IN

A Table Driven ODS Macro Diane E. Brown, exponential Systems, Indianapolis, IN A Table Driven ODS Macro Diane E. Brown, exponential Systems, Indianapolis, IN ABSTRACT Tired of coding ODS statements and SAS output procedures for every report you write and having redundant or similar

More information

Subquery: There are basically three types of subqueries are:

Subquery: There are basically three types of subqueries are: Subquery: It is also known as Nested query. Sub queries are queries nested inside other queries, marked off with parentheses, and sometimes referred to as "inner" queries within "outer" queries. Subquery

More information

Using Proc Freq for Manageable Data Summarization

Using Proc Freq for Manageable Data Summarization 1 CC27 Using Proc Freq for Manageable Data Summarization Curtis Wolf, DataCeutics, Inc. A SIMPLE BUT POWERFUL PROC The Frequency procedure can be very useful for getting a general sense of the contents

More information

Advanced SQL Processing Prepared by Destiny Corporation

Advanced SQL Processing Prepared by Destiny Corporation Advanced SQL Processing Prepared by Destiny Corporation Summary Functions With a single argument, but with other selected columns, the function gives a result for all the rows, then merges the back with

More information

Amie Bissonett, inventiv Health Clinical, Minneapolis, MN

Amie Bissonett, inventiv Health Clinical, Minneapolis, MN PharmaSUG 2013 - Paper TF12 Let s get SAS sy Amie Bissonett, inventiv Health Clinical, Minneapolis, MN ABSTRACT The SAS language has a plethora of procedures, data step statements, functions, and options

More information

CHAPTER 7 Using Other SAS Software Products

CHAPTER 7 Using Other SAS Software Products 77 CHAPTER 7 Using Other SAS Software Products Introduction 77 Using SAS DATA Step Features in SCL 78 Statements 78 Functions 79 Variables 79 Numeric Variables 79 Character Variables 79 Expressions 80

More information

Turbo charging SAS Data Integration using SAS In-Database technologies Paul Jones

Turbo charging SAS Data Integration using SAS In-Database technologies Paul Jones Turbo charging SAS Data Integration using SAS In-Database technologies Paul Jones Agenda What is SAS In-Database Why do we do Who are we working with.. When? How.does it work What is SAS In-Database? Integration

More information

An Introduction to SAS/FSP Software Terry Fain, RAND, Santa Monica, California Cyndie Gareleck, RAND, Santa Monica, California

An Introduction to SAS/FSP Software Terry Fain, RAND, Santa Monica, California Cyndie Gareleck, RAND, Santa Monica, California An Introduction to SAS/FSP Software Terry Fain, RAND, Santa Monica, California Cyndie Gareleck, RAND, Santa Monica, California ABSTRACT SAS/FSP is a set of procedures used to perform full-screen interactive

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

NEW FEATURES OF ENTERPRISE GUIDE 6.1 MATT MALCZEWSKI, SAS CANADA

NEW FEATURES OF ENTERPRISE GUIDE 6.1 MATT MALCZEWSKI, SAS CANADA NEW FEATURES OF ENTERPRISE GUIDE 6.1 MATT MALCZEWSKI, SAS CANADA AGENDA NEW FEATURES FOR General Users SAS Programmers Data Analysts Miscellaneous New Tasks FYI Enterprise Guide 6.1 is compatible with

More information

Uncommon Techniques for Common Variables

Uncommon Techniques for Common Variables Paper 11863-2016 Uncommon Techniques for Common Variables Christopher J. Bost, MDRC, New York, NY ABSTRACT If a variable occurs in more than one data set being merged, the last value (from the variable

More information

EXISTS NOT EXISTS WITH

EXISTS NOT EXISTS WITH Subquery II. Objectives After completing this lesson, you should be able to do the following: Write a multiple-column subquery Use scalar subqueries in SQL Solve problems with correlated subqueries Update

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

A Format to Make the _TYPE_ Field of PROC MEANS Easier to Interpret Matt Pettis, Thomson West, Eagan, MN

A Format to Make the _TYPE_ Field of PROC MEANS Easier to Interpret Matt Pettis, Thomson West, Eagan, MN Paper 045-29 A Format to Make the _TYPE_ Field of PROC MEANS Easier to Interpret Matt Pettis, Thomson West, Eagan, MN ABSTRACT: PROC MEANS analyzes datasets according to the variables listed in its Class

More information

SAS Information Map Studio 3.1: Tips and Techniques

SAS Information Map Studio 3.1: Tips and Techniques SAS Information Map Studio 3.1: Tips and Techniques The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2006. SAS Information Map Studio 3.1: Tips and Techniques. Cary,

More information

10 The First Steps 4 Chapter 2

10 The First Steps 4 Chapter 2 9 CHAPTER 2 Examples The First Steps 10 Invoking the Query Window 11 Changing Your Profile 11 ing a Table 13 ing Columns 14 Alias Names and Labels 14 Column Format 16 Creating a WHERE Expression 17 Available

More information

Chapter 3. Introducation to Relational Database 9/2/2014 CSC4341 1

Chapter 3. Introducation to Relational Database 9/2/2014 CSC4341 1 Chapter 3 Introducation to Relational Database 9/2/2014 CSC4341 1 Relational Model Structure aspect Data in the database is perceived by the user as tables and nothing but tables Integrity aspect Those

More information

How To Insert Data In Two Tables At A Time In Sql Server 2008

How To Insert Data In Two Tables At A Time In Sql Server 2008 How To Insert Data In Two Tables At A Time In Sql Server 2008 Below is a similar example to my first INSERT statement, but this time I have left off the column list: With the introduction of SQL Server

More information

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement GIFT Department of Computing Science [Spring 2013] CS-217: Database Systems Lab-2 Manual Data Selection and Filtering using the SELECT Statement V1.0 4/12/2016 Introduction to Lab-2 This lab reinforces

More information

PROC FORMAT Tips. Rosalind Gusinow 2997 Yarmouth Greenway Drive u Madison, WI (608) u

PROC FORMAT Tips. Rosalind Gusinow 2997 Yarmouth Greenway Drive u Madison, WI (608) u PROC FORMAT Tips Rosalind Gusinow 2997 Yarmouth Greenway Drive u Madison, WI 53711 (608) 278-9964 u www.sys-seminar.com 1 Proc Format - Viewing Formats Review the creation of formats: Proc Format; Value

More information

Journey to the center of the earth Deep understanding of SAS language processing mechanism Di Chen, SAS Beijing R&D, Beijing, China

Journey to the center of the earth Deep understanding of SAS language processing mechanism Di Chen, SAS Beijing R&D, Beijing, China Journey to the center of the earth Deep understanding of SAS language processing Di Chen, SAS Beijing R&D, Beijing, China ABSTRACT SAS is a highly flexible and extensible programming language, and a rich

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

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

Limit Rows Selected. Copyright 2008, Oracle. All rights reserved.

Limit Rows Selected. Copyright 2008, Oracle. All rights reserved. What Will I Learn? In this lesson, you will learn to: Apply SQL syntax to restrict the rows returned from a query Demonstrate application of the WHERE clause syntax Explain why it is important, from a

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

AN INTRODUCTION TO THE SQL PROCEDURE Chris Yindra, C. Y. Associates

AN INTRODUCTION TO THE SQL PROCEDURE Chris Yindra, C. Y. Associates Abstract AN INTRODUCTION TO THE SQL PROCEDURE Chris Yindra, C Y Associates This tutorial will introduce the SQL (Structured Query Language) procedure through a series of simple examples We will initially

More information

IPUMS Training and Development: Requesting Data

IPUMS Training and Development: Requesting Data IPUMS Training and Development: Requesting Data IPUMS PMA Exercise 2 OBJECTIVE: Gain an understanding of how IPUMS PMA service delivery point datasets are structured and how it can be leveraged to explore

More information

And Answers In Oracle Pl Sql

And Answers In Oracle Pl Sql Most Frequently Asked Interview Questions And Answers In Oracle Pl Sql To be successful with database-centric applications (which includes most of the in the form of several question-answer sessions commonly

More information

Get SAS sy with PROC SQL Amie Bissonett, Pharmanet/i3, Minneapolis, MN

Get SAS sy with PROC SQL Amie Bissonett, Pharmanet/i3, Minneapolis, MN PharmaSUG 2012 - Paper TF07 Get SAS sy with PROC SQL Amie Bissonett, Pharmanet/i3, Minneapolis, MN ABSTRACT As a data analyst for genetic clinical research, I was often working with familial data connecting

More information