BookmarkSubscribeRSS Feed
Ravindra_
Quartz | Level 8

I have got below requirement

For the Same FormSeq
If T1TIMP = NOT NULL
THEN
the timepoint entered on T1TIMP should match with the timepoint entered on T2TIMP and T3TIMP for the same FormSeq. If not, then output.

 

What i am trying to do is writing multiple if then else condition which is getting really tedious, is there any efficient way to do this in one or two steps.

example dataset below:

data ndsn;
infile datalines;
input subjid $8. formseq  T1TIMP $11. T2TIMP $15. T3TIMP $11.;
datalines;
ABCD123 1 PRE-DOSE     1.5HRS-POST  3HRS-POST
ABCD123 1 1.5HRS-POST  1.5HRS-POST  1.5HRPOST
ABCD123 1 1.5HRS-POST  3HRS-POST    1HRPOST
ABCD145 2 3.5HRS-POST  2HRS-POST    6HRPOST
ABCD168 2 2HRS-POST    6HRS-POST    8HRPOST
ABCD167 3 1.5HRS-POST  12HRS-POST   1HRPOST
ABCD167 3 1.5HRS-POST  3HRS-POST    2HRPOST
;
run;

any help please

The expected output should be as below, excluding the second row which is having all values matching for same formseq, sometimes they were not in one single row and i am trying to flag them if the values were not matching for the same formseq.

ABCD123 1 PRE-DOSE     1.5HRS-POST  3HRS-POST
ABCD123 1 1.5HRS-POST  3HRS-POST    1HRPOST
ABCD145 2 3.5HRS-POST  2HRS-POST    6HRPOST
ABCD168 2 2HRS-POST    6HRS-POST    8HRPOST
ABCD167 3 1.5HRS-POST  12HRS-POST   1HRPOST
ABCD167 3 1.5HRS-POST  3HRS-POST    2HRPOST
6 REPLIES 6
Kurt_Bremser
Super User

And what would be the expected output rom this example dataset? Please state for every result observation why it has to be included.

 


@Ravindra_ wrote:

I have got below requirement

For the Same FormSeq
If T1TIMP = NOT NULL
THEN
the timepoint entered on T1TIMP should match with the timepoint entered on T2TIMP and T3TIMP for the same FormSeq. If not, then output.

 

What i am trying to do is writing multiple if then else condition which is getting really tedious, is there any efficient way to do this in one or two steps.

example dataset below:

data ndsn;
infile datalines;
input subjid $8. formseq  T1TIMP $11. T2TIMP $15. T3TIMP $11.;
datalines;
ABCD123 1 PRE-DOSE     1.5HRS-POST  3HRS-POST
ABCD123 1 1.5HRS-POST  1.5HRS-POST  1.5HRPOST
ABCD123 1 1.5HRS-POST  3HRS-POST    1HRPOST
ABCD145 2 3.5HRS-POST  2HRS-POST    6HRPOST
ABCD168 2 2HRS-POST    6HRS-POST    8HRPOST
ABCD167 3 1.5HRS-POST  12HRS-POST   1HRPOST
ABCD167 3 1.5HRS-POST  3HRS-POST    2HRPOST
;
run;

any help please


 

Kurt_Bremser
Super User

See this:

data ndsn;
infile datalines;
input subjid $8. formseq  T1TIMP $11. T2TIMP $15. T3TIMP $11.;
datalines;
ABCD123 1 PRE-DOSE     1.5HRS-POST  3HRS-POST
ABCD123 1 1.5HRS-POST  1.5HRS-POST  1.5HRS-POST
ABCD123 1 1.5HRS-POST  3HRS-POST    1HRPOST
ABCD145 2 3.5HRS-POST  2HRS-POST    6HRPOST
ABCD168 2 2HRS-POST    6HRS-POST    8HRPOST
ABCD167 3 1.5HRS-POST  12HRS-POST   1HRPOST
ABCD167 3 1.5HRS-POST  3HRS-POST    2HRPOST
;

data want;
set ndsn;
if not (T1TIMP = T2TIMP and T2TIMP = T3TIMP);
run;

Note that I had to edit the second observation of the source data.

Ravindra_
Quartz | Level 8
I need to do these on multiple visits Kurt, will there be any issues

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1956 views
  • 0 likes
  • 2 in conversation