BookmarkSubscribeRSS Feed
Vijay77
Fluorite | Level 6

I need output only if below condition satisfies

 

Output if, Sample ID "Serum" is present in dataset A  and (COL) = NO or MISSING in the dataset B for same acc ID.
Populate NEW_VAR: Sample not collected in B

2 REPLIES 2
andreas_lds
Jade | Level 19

Please post data in usable form and describe exactly the expected result.

Patrick
Opal | Level 21

You need to help us help you by providing sample data (via a working SAS datastep), show the desired result and explain the logic to get from have to want.

The following code totally based on assumptions and untested.  ....and I won't answer any questions unless you provide at least sample data via a data step which I just can copy/paste into a code window and execute.

data want;
  if _n_=1 then 
    do;
      if 0 then set b(keep=acc_id col);
      dcl hash h1(dataset:'b(keep=acc_id col where=(col in (' ','NO')))');
      h1.defineKey('acc_id');
      h1.defineDone();
    end;

  set a;
  if sample_id='Serum' and h1.check()=0 then output;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 354 views
  • 0 likes
  • 3 in conversation