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 now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.