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;
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;
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;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.