BookmarkSubscribeRSS Feed
Calcite | Level 5

There is no Adverse Event reported on Adverse Event Form where


If atleast in any of the logline aedis=yes then it should not fetch in the output. Can anyone suggest a solution?


Please post data in usable form so that we have something to work with. Also show what you expect as output.

Calcite | Level 5

logic: DS.DSDECOD = Adverse Event
There is no Adverse Event reported on Adverse Event Form where

subject    aedis   dsdecod
1001          Yes      Adverse event
1001          blank    Adverse event

1001        no           Adverse event

Like above example, a subject has 3 loglines and in one of the logline it is present as aedis=yes , so this subject should not come in output.
code for this ??


When posting data make sure that

  • you post the data as working data step code
  • and that all cases that exist in your real data are present at least once.

Idea to solve the problem:

  • create a dataset containing all obs with "Adverse event"
  • use that dataset to create another one having only those obs with aedis = "Yes"
  • finally something like this:
proc sql noprint;
  create table work.want as
    select * from work.adverse_events
     where subject not in (select subject from work.aedis)

Code is, of course, untested. Using a single step with two dow-loops seems to be the better approach, as less iteration are required.

Jade | Level 19

In the absence of sample data in the form of a working data step, the code below is untested.

Assuming your data is in a dataset named HAVE and the data is sorted by subject, then:


data want;
  merge have (where=(dsdecod='Adverse event') in=unwanted)
        have ;
  by subject;
  if unwanted=0;



The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

Super User

Is this one of those questions where ALL of the values for single person has to be considered?

If so you need to state such before getting into any coding. SAS data steps where any such code is likely to be used processes data sets one observation at a time. If something has to consider more than one observation for a 'correct' answer than that criteria has to be explicitly stated and described properly to implement.



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!

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.

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
  • 5 replies
  • 1 like
  • 4 in conversation