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,
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.
Is this in SAS Clinical?
Yes in SDTM clinical SAS.
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 🙂
ok thank you.
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.
Thank you.
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →
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.