What is interleaving in SAS?
Can you elaborate? In what context are you in doubt of the term 'interleave'?
Interleaving refers to a DATA step that uses:
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.
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.
Cynthia
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.