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: 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!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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