BookmarkSubscribeRSS Feed
anjita
Fluorite | Level 6

 What is interleaving in SAS?

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

Can you elaborate? In what context are you in doubt of the term 'interleave'? 

Astounding
PROC Star

Interleaving refers to a DATA step that uses:

 

  • a SET statement with more than one data set
  • a BY statement.

For example:

 

data want;

set a b;

by id;

run;

 

The incoming data sets must all be in sorted order (by ID in this case), and the output will also be in sorted order.

Cynthia_sas
SAS Super FREQ

Hi:

  Here's a comparison of 2 techniques:

1) Concatenation of the data, then sorting

2) Using 2 (or more) SET statements with BY group processing.

about_interleave.png

 

Cynthia

rinugour
Fluorite | Level 6

Interleaving combines individual, sorted SAS data sets into one sorted SAS data set. For each observation, the following figure shows the value of the variable by which the data sets are sorted. You interleave data sets using a SET statement along with a BY statement.
In the following example, the data sets are sorted by the variable Year.
We can sort and then join the datasets on Year with the below code.

  1. Data combined;
  2. Set data1 data2
  3. By Year;
  4. Run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2213 views
  • 2 likes
  • 5 in conversation