You deserve ARRAYs! How to be more efficient using SAS®

Slides:



Advertisements
Similar presentations
Computer Science 1620 Programming & Problem Solving.
Advertisements

ECE 284: Special Topics in Computer Engineering On-Chip Interconnection Networks Prof. Bill Lin Spring 2014.
INDIVIDUAL ACHIEVEMENT. EDUCATIONAL EXCELLENCE. ADMINISTRATIVE INNOVATION. INSTITUTIONAL PERFORMANCE. 1 Class Title Presented by: Presenter name(s), Institution(s)
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 9 Arrays.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 10 - JavaScript/JScript: Control Structures II Outline 10.1Introduction 10.2Essentials of.
ITCS 6265 Details on Project & Paper Presentation.
“Come out of the desert of ignorance to the OASUS of knowledge” Put Data in the Driver's Seat Andrew Clapson, MD Financial Management.
BEYOND BIBLIOGRAPHIC INSTRUCTION: SCIENCE RESEARCH WORKSHOPS Christina Chan-Park, Baylor University Texas STEM Librarian Conference 2015.
Cen 112 C Programming Özgür Örnek.
Research topics Facebook revolution (Arab spring)
Using ODS Excel Migrating from DDE to ODS
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Membean Grading Guidelines.
The Scientific Method 7th Grade Life Science.
Bell Ringer Procedure.
Ms. Stout’s 4th grade Weekly Homework October 2nd-6th, 2017
Honors British Literature
Ms. Stout’s 4th grade Weekly Homework September 11th-15th, 2017
Arrays Part-1 Armen Keshishian.
WELCOME TO AP COMPUTER SCIENCE PRINCIPLES!
Gigabit Ethernet Design ECE 4006C – Spring 2003
DAYS OF THE WEEK.
Monday.
Sprint 5 Schedule (15 – 2 days)
Fall 2017 Questions and Answers (Q&A)
Monday 10/10 Warm-Up Please respond on notebook paper and be ready to turn it in. 1) How do you feel about your current grade? 2) What challenges are you.
MATLAB – Basic For Loops
Review for Final Exam.
Workshop hours.
SP10/ WK-2.
How to Create Data Driven Lists
Geography of Sports Spring 2010
Starting Out with Programming Logic & Design
Language Arts Weekly Homework
Let’s all Repeat Together
Review for Final Exam.
Automate Repetitive Programming Tasks: Effective SAS® Code Generators
9A HW: April 22-25, 2014 RESEARCH PAPER TOPIC DUE FRIDAY: your top 4 choices. Tuesday: Complete vocabulary unit 11 for next week. Wednesday: Study for.
Unit #1: Earning Income.
Lecture 15: Inheritance II
CS 240 – Lecture 7 Boolean Operations, Increment and Decrement Operators, Constant Types, enum Types, Precedence.
General recommendations
#1. 5(m-3) #2. (4-z)( -2) #3. 5/15 + 1/3 #4. 1/5 + 6/20
No Warm-Up 5/15/17 Happy Monday!  We have 9 school days left this year! (and 1 more Monday after today!) You can choose your seat today; if you move.
Role Audience Format Topic
Student Research Conference 2019
Arrays type Int_Buffer is array (1..10) of Integer;
Home of the Mighty Eagles!
Bring Your Family to School Night
Home of the Mighty Eagles!
Contact
No Warm-Up 5/19/17 Happy Friday!  We have 5 school days left this year! You can choose your seat today; if you move the seats around, please put them.
This Week’s Schedule Monday – Pre-Writing Phase / Quiz-Quiz-Trade
Returning Speech Team Welcome to the Season!
Title Introduction: Discussion & Conclusion: Methods & Results:
Basic Matrix Operations
February 2018 Monday Tuesday Wednesday Thursday Friday
Learning Strategies February 13th , 2018.
7th Grade Math Warm-ups Week of September 7-11, 2015.
Rolesville High School Senior Project
Week of February 3-7, 2014 Warm-ups.
NOVEMBER READING LOG Student: When you have read, record your minutes and have your parent initial the proper box (each day). At the end of the month,
WEEK 1 Monday Tuesday Wednesday Thursday Friday Saturday Sunday
Week of October 28- November 1, 2013
No Warm-Up 5/18/17 Happy Thursday!  We have 6 school days left this year! (and 1 more Thursday after today!) You can choose your seat today; if you.
Group Assignments Consult about Poster / Talk
On and At Unit 2 Fun after school.
Bell Work Each Friday, students will be given a bell work quiz consisting of one question from each day’s bell work that week. On the following slides.
Weekly Class Opener August 29-September 2,2016.
Welcome to sixth grade! 09/16/2019
Presentation transcript:

You deserve ARRAYs! How to be more efficient using SAS® By: Kate Burnett-Isaacs Presented at SAS Global Forum 2015

Introduction An array is a group of related variables defined in a DATA step Arrays are extremely useful when a repetitive process, such as a calculation, transformation or function, needs to be applied to a large set of variables An array enables the programmer to set a list of variables once and then refer this list, or elements within the list, any number of times within a single DATA step #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.

Establishing The Array We define an array in an ARRAY statement within the DATA step by the keyword ‘array’ : Array name: array_name Length of the array: {N} or {*} Variables or array elements that it will contain: variable1 … variableN All array elements must be character or numeric array array_name {N} variable1 … variableN; #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.

Using The Array The number in the braces indicates the corresponding element in the array To refer variable2: To apply a repetitive process to a large set of variables, use the DO loop: Use all of the array elements together in the calculation of the sum or mean with OF operator: array_name {2}; do i=1 to dim(array_name); array_name {i}=i; end; Total=sum(of array_name {*}); #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.

Example You are an employer, whose employees took a week long SAS course If they were absent, no grade is present To reward participation, each employee gets 2% of their weekly earnings for every day they attend the course You want to show your employees how much they made each day of the course and what their total weekly salary will be at the end of the week long course #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.

Example Dataset #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.

Example with IF-ELSE Statement data No_Arrays; set SAS_scores; if NOT MISSING(Monday) then BnsMon=(Wkearn*0.02); else BnsMon=0; if NOT MISSING(Tuesday) then BnsTues=(Wkearn*0.02); else BnsTues=0; if NOT MISSING(Wednesday) then BnsWed=(Wkearn*0.02); else BnsWed=0; if NOT MISSING(Thursday) then BnsThurs=(Wkearn*0.02); else BnsThurs=0; if NOT MISSING(Friday) then BnsFri=(Wkearn*0.02); else BnsFri=0; fnlearn=wkearn+sum(BnsMon, BnsTues, BnsWed, BnsThurs, BnsFri); keep Name BnsMon BnsTues abWed BnsThurs BnsFri fnlearn; run; we would use an IF-ELSE statement for each day of the week in order to create a daily bonus variable (bnsMon-bnsFri) that reflects the amount earned by each employee for each day of the week they attended the SAS course. In order to determine the final weekly earnings (fnlearn), any daily bonuses attained will be added to the weekly earnings of each employee This method is fairly tedious to code and error-prone. Imagine the number of IF-ELSE statements needed to conduct these calculations over several months or even a year, instead of a week! #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.

Example with Arrays data Using_Arrays; set SAS_scores; array array_day {*} Monday Tuesday Wednesday Thursday Friday; array bonus {*} BnsMon BnsTues BnsWed BnsThurs BnsFri; do i=1 to dim(array_day); if NOT MISSING(array_day {i}) then bonus{i}=Wkearn*(0.02); else bonus {i}=0; end; fnlearn=(wkearn+sum(of bonus {*})); keep Name BnsMon BnsTues abWed BnsThurs BnsFri fnlearn; run; #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.

Results Copyright © 2013, SAS Institute Inc. All rights reserved. #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.

Conclusion Arrays can easily scale with the size of the program and the data, the time and effort saved will also increase accordingly An array is a very useful tool when repetitively processing large sets of variables. Arrays allow repetitive code to be more efficiently executed and less prone to coding mistakes. Use arrays and in no time you will receive your raise! #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.

The SAS Global Forum Experience OASUS Spring or Fall YYYY Thursday, February-28-19 The SAS Global Forum Experience First & last name Company name

OASUS Spring or Fall YYYY Thursday, February-28-19 Process Idea Session Choice Application Process Presenting First & last name Company name

How to Choose a Paper Topic What you found challenging in your own SAS experience What you would like to learn more about Some code, techniques or process that you have created which is rather unique

Session Choice Quick Tip Breakout Session Poster Table Talk

Application Process Apply on SAS Global Forum website Abstract Draft paper Catchy title

Presenting Minimal text or code on the slides At most, one slide per minute Leave time for questions Know your audience

OASUS Spring or Fall YYYY Thursday, February-28-19 At SAS Global Forum Experience as much as you can Choose the presentations you attend wisely Network First & last name Company name

OASUS Spring or Fall YYYY Thursday, February-28-19 Questions? Thursday, February-28-19 First & last name Company name First & last name Company name