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
Super User

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
Super User

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 2024

Innovate_SAS_Blue.png

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. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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