As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Tips:Interleaving

From sasCommunity
Jump to: navigation, search

Interleaving is used to combine datasets (each of them individually sorted) together into a sorted combined dataset. It is quite easy to do with a SET statement accompanied by BY statement. Here is an example of interleaving three datasets by id.

/* test data */
data one two three;
  id=3; v="c"; output one;
  id=1; v="a"; output two;
  id=2; v="b"; output two;
  id=5; v="e"; output three;
  id=4; v="d"; output three;
run;
 
/* sort each dataset by id */
proc sort data=one; by id; run;
proc sort data=two; by id; run;
proc sort data=three; by id; run;
 
/* interleave */
data all;
  set one two three;
  by id;
run;

Submitted by Chang Y. Chung. Contact me at my Discussion Page.

....see also