Sample 24685: Merge two data sets with no common variable
Perform a One-to-One MERGE by combining two data sets
horizontally. No BY statement is used. Observations are
combined based upon their relative position in each data
set, ie, observation one from the first data set
combines with observation one of the second data set, the
second observation from the first data set combines with
the second observation from the second data set,
and so on.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/* Note the data sets are arranged in the same order by */
/* the value of NAME. Zoe exists only in WORK.TWO. */
data one;
input name $ age;
datalines;
Chris 36
Jane 21
Jerry 30
Joe 49
;
data two;
input name $ salary;
format salary dollar10.;
datalines;
Chris 33000
Jane 40000
Jerry 60000
Joe 26000
Zoe 60000
;
data both;
merge one two;
run;
proc print data=both;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Obs name age salary
1 Chris 36 $33,000
2 Jane 21 $40,000
3 Jerry 30 $60,000
4 Joe 49 $26,000
5 Zoe . $60,000
Perform a One-to-One MERGE by combining two data sets
horizontally. No BY statement is used.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Statements ==> File-handling ==> MERGE Common Programming Tasks ==> Combining Data
|
| Date Modified: | 2008-02-21 11:21:34 |
| Date Created: | 2004-09-30 14:09:04 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |