BookmarkSubscribeRSS Feed

A Beginners Guide to Using Arrays and DO Loops

Started ‎07-06-2020 by
Modified ‎07-07-2020 by
Views 3,606

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.

 

 

 

 

 

Video highlights

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

 

Read the Paper

Related resources

GitHub materials

How to Restructure Your Data Using Arrays and DO Loops (YouTube tutorial)

 

Version history
Last update:
‎07-07-2020 03:52 PM
Updated by:
Contributors

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags