Friday, August 29, 2008

How to determine which data set contributed an observation

Determine which data set contributed an observation

Use the IN= 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.

data one;
input string $;datalines;
apple
banana
coconut; run;

data two;
input string $;
datalines;
anagram
bottle
clown
dog; run;

data combo;
set one(in=o) two(in=t);
if o then origin='one';
else origin='two';
run;

proc print data=combo;run;
run;

RESULTS:

Obs string origin
1 apple one
2 banana one
3 coconut one
4 anagram two
5 bottle two
6 clown two
7 dog two

source: www.support.sas.com

0 comments:

Post a Comment

ShareThis