BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Fluorite | Level 6

## 1 if one or more PK samples for the subject are ADA Negative

Hello Community.

I need to create one variable where I have to derive if in PK sample for the particular subject has one or more Negative result then create new variable ADAT and give value =1. Following is example of data.

Please guide what to write in code to get that value. It's urgent need help ASAP

 Subject DATE PK result 1001 6-Mar-13 Positive 1001 7-Mar-13 Positive 1001 8-Mar-13 Positive 1001 9-Mar-13 Positive 1002 6-Mar-13 Positive 1002 7-Mar-13 Negative 1002 8-Mar-13 Positive 1002 9-Mar-13 Positive 1002 10-Mar-13 Positive 1003 7-Mar-13 Positive 1003 8-Mar-13 Positive 1003 9-Mar-13 Positive 1003 10-Mar-13 Positive 1003 11-Mar-13 Positive 1004 6-Mar-13 Negative 1004 7-Mar-13 Negative 1004 8-Mar-13 Positive 1004 9-Mar-13 Positive 1004 10-Mar-13 Positive
1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: 1 if one or more PK samples for the subject are ADA Negative

``````data have;
infile cards expandtabs;
input (Subject  DATE PK_result) (: \$20.);
cards;
1001 6-Mar-13 Positive
1001 7-Mar-13 Positive
1001 8-Mar-13 Positive
1001 9-Mar-13 Positive
1002 6-Mar-13 Positive
1002 7-Mar-13 Negative
1002 8-Mar-13 Positive
1002 9-Mar-13 Positive
1002 10-Mar-13 Positive
1003 7-Mar-13 Positive
1003 8-Mar-13 Positive
1003 9-Mar-13 Positive
1003 10-Mar-13 Positive
1003 11-Mar-13 Positive
1004 6-Mar-13 Negative
1004 7-Mar-13 Negative
1004 8-Mar-13 Positive
1004 9-Mar-13 Positive
1004 10-Mar-13 Positive
;

proc sql;
create table want as
select *,ifn(sum(PK_result='Negative'),1,0) as ADAT
from have
group by Subject;
quit;``````
2 REPLIES 2
Super User

## Re: 1 if one or more PK samples for the subject are ADA Negative

``````data have;
infile cards expandtabs;
input (Subject  DATE PK_result) (: \$20.);
cards;
1001 6-Mar-13 Positive
1001 7-Mar-13 Positive
1001 8-Mar-13 Positive
1001 9-Mar-13 Positive
1002 6-Mar-13 Positive
1002 7-Mar-13 Negative
1002 8-Mar-13 Positive
1002 9-Mar-13 Positive
1002 10-Mar-13 Positive
1003 7-Mar-13 Positive
1003 8-Mar-13 Positive
1003 9-Mar-13 Positive
1003 10-Mar-13 Positive
1003 11-Mar-13 Positive
1004 6-Mar-13 Negative
1004 7-Mar-13 Negative
1004 8-Mar-13 Positive
1004 9-Mar-13 Positive
1004 10-Mar-13 Positive
;

proc sql;
create table want as
select *,ifn(sum(PK_result='Negative'),1,0) as ADAT
from have
group by Subject;
quit;``````
Fluorite | Level 6

## Re: 1 if one or more PK samples for the subject are ADA Negative

Thank you so much. it worked

Discussion stats
• 2 replies
• 284 views
• 0 likes
• 2 in conversation