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)
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.