If you're copying and pasting code over and over to perform the same operation on multiple variables in a SAS DATA step, you need to learn about arrays and DO loops. Arrays and DO loops are efficient and powerful data manipulation tools that belong in your programmer’s toolbox. In this 20-minute workshop, you'll learn how to create an array and use DO loops to perform operations on the elements in an array, create new variables, and change a short and wide data structure to a long and skinny one.
00:40 - What is an array?
01:22 - What is a DO loop?
04:47 - Syntax of an array
05:34 - For indexed array, indicate number of elements in curly brackets
05:49 - Character variables? Designate array with dollar sign
06:00 - Other options for variables
08:12 - Start with array statement, end with semicolon
11:46 - How to reference an array in an interative DO loop or indexed DO loop
15:19 - Example of a do-over loop with a non-indexed array
How to Restructure Your Data Using Arrays and DO Loops (YouTube tutorial)
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.