Sample 24747: Determine which data set contributed the current observation
The sample code on the Full Code tab illustrates how to use the IN= data set option to create a Boolean variable that is set to one or 'true' to indicate whether the data set contributed data to the current observation. When the IN= variable's value is 1, assign the data set's name into a new variable.
In SAS® 9.2 and later, the INDSNAME= option for the SET statement writes the name of the currently read data set to the variable name specified. See Sample 34513, "Obtain the name of data set being read with SET statement with INDSNAME= option", for more information.
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.
data one;
input string $;
datalines;
apple
banana
coconut
;
data two;
input string $;
datalines;
anagram
bottle
clown
dog
;
data combo;
set one(in=o) two(in=t);
if o then origin='one';
else origin='two';
run;
proc print data=combo;
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 string origin
1 apple one
2 banana one
3 coconut one
4 anagram two
5 bottle two
6 clown two
7 dog two
Use the IN= data set option to create a boolean variable that is set to one or 'true' to indicate whether the data set contributed data to the current observation.
| Type: | Sample |
| Topic: | Common Programming Tasks ==> Combining Data SAS Reference ==> DATA Step SAS Reference ==> Statements ==> File-handling ==> SET SAS Reference ==> Statements ==> File-handling ==> SET ==> with IN= Data Management
|
| Date Modified: | 2012-06-20 14:23:07 |
| Date Created: | 2004-09-30 14:09:10 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |