Discover More Tips and Techniques on This Blog

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

No comments:

Post a Comment

Disclosure:

In the spirit of transparency and innovation, I want to share that some of the content on this blog is generated with the assistance of ChatGPT, an AI language model developed by OpenAI. While I use this tool to help brainstorm ideas and draft content, every post is carefully reviewed, edited, and personalized by me to ensure it aligns with my voice, values, and the needs of my readers. My goal is to provide you with accurate, valuable, and engaging content, and I believe that using AI as a creative aid helps achieve that. If you have any questions or feedback about this approach, feel free to reach out. Your trust and satisfaction are my top priorities.