BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Hsas
Calcite | Level 5

Hi,

 

How to populate --TESTCD for the NOT DONE records in an SDTM dataset. eg.

in VS dataset per subject if there are 5 parameters out of which if one is not done then the TESTCD should be of that parameter and VSSTAT=NOT DONE. However for this visit if all parameters are NOT DONE then the entire panerfor that visit per subject should be collapsed to 1record with VSTESTCD=VSALL. How can this be done using SAS? Please help.

 

Thanks,

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, if you can code its pretty simple:

data have;
  length usubjid vstestcd vsstatus $20;
  usubjid="001"; vstestcd="PULSE"; vsstatus=""; output;
  usubjid="001"; vstestcd="HEIGHT"; vsstatus=""; output;
  usubjid="002"; vstestcd="PULSE"; vsstatus="NOT DONE"; output;
  usubjid="002"; vstestcd="HEIGHT"; vsstatus="NOT DONE"; output;
run;

proc sql;
  create table WANT as
  select  *
  from    HAVE
  where   USUBJID not in (select distinct USUBJID from (select * from HAVE where VSSTATUS="NOT DONE") group by USUBJID having count(*)=2)
  union all
  select  distinct
          USUBJID,
          "VSALL" as VSTESTCD,
          VSSTATUS
  from    HAVE
  where   USUBJID in (select distinct USUBJID from (select * from HAVE where VSSTATUS="NOT DONE") group by USUBJID having count(*)=2);
quit;

Obviously change it to match your data.

View solution in original post

7 REPLIES 7
LinusH
Tourmaline | Level 20
Sorry, but what are you talking about?
Data never sleeps
Reeza
Super User

Is this in SAS Clinical?

Hsas
Calcite | Level 5

Yes in SDTM clinical SAS.

Reeza
Super User

I've moved your post to the Healthcare forum. That said there aren't a lot of people who use this particular application on here. 

 

I would highly recommend contacting SAS Tech Support. That's what you pay them for after all 🙂

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, if you can code its pretty simple:

data have;
  length usubjid vstestcd vsstatus $20;
  usubjid="001"; vstestcd="PULSE"; vsstatus=""; output;
  usubjid="001"; vstestcd="HEIGHT"; vsstatus=""; output;
  usubjid="002"; vstestcd="PULSE"; vsstatus="NOT DONE"; output;
  usubjid="002"; vstestcd="HEIGHT"; vsstatus="NOT DONE"; output;
run;

proc sql;
  create table WANT as
  select  *
  from    HAVE
  where   USUBJID not in (select distinct USUBJID from (select * from HAVE where VSSTATUS="NOT DONE") group by USUBJID having count(*)=2)
  union all
  select  distinct
          USUBJID,
          "VSALL" as VSTESTCD,
          VSSTATUS
  from    HAVE
  where   USUBJID in (select distinct USUBJID from (select * from HAVE where VSSTATUS="NOT DONE") group by USUBJID having count(*)=2);
quit;

Obviously change it to match your data.

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch Now →

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 7 replies
  • 7025 views
  • 1 like
  • 4 in conversation