BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mauri0623
Quartz | Level 8

I have merged two table together for the purpose of table lookup. I want the pips dataset to lookup the dai_fixed dataset for the variables task_number, loa, and tas. The code does that. What else I want the code to do is if it find the match I want it to place it in a pips_dai_match and if not place it in another dataset called error. Below is the code.

 

data PIPS_DAI_Match(drop=rc);

if 0 then set work.dai_fixed;

if _N_ = 1 then do;

declare hash h(dataset:'work.dai_fixed');

h.defineKey('project_number');

h.defineData('task_number', 'loa', 'tas');

 

h.defineDone();

call missing(task_number, loa, tas);

end;

 

 

set pips;

 

 

rc=h.find();

run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

A small correction will give you what you want

 

data PIPS_DAI_Match error(drop=rc);
if 0 then set work.dai_fixed;
if _N_ = 1 then do;
declare hash h(dataset:'work.dai_fixed');
h.defineKey('project_number');
h.defineData('task_number', 'loa', 'tas');
h.defineDone();
call missing(task_number, loa, tas);
end;

set pips;

if h.find()=0 then output PIPS_DAI_Match;
else output error

run;

View solution in original post

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

A small correction will give you what you want

 

data PIPS_DAI_Match error(drop=rc);
if 0 then set work.dai_fixed;
if _N_ = 1 then do;
declare hash h(dataset:'work.dai_fixed');
h.defineKey('project_number');
h.defineData('task_number', 'loa', 'tas');
h.defineDone();
call missing(task_number, loa, tas);
end;

set pips;

if h.find()=0 then output PIPS_DAI_Match;
else output error

run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 905 views
  • 0 likes
  • 2 in conversation