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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 755 views
  • 0 likes
  • 2 in conversation