cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
dhagman
Level I

how to select only those samples that meet two or more criteria

dhagman_0-1663861180563.png

i want to create a new column using Day1_Orig values wherein there are both Day1_Orig and Day1_Repeat values for the same SUBJID. So for instance, lines 113 and 114 have same SUBJID, so the new column would record the value of the Day1_Orig value in line 113 (834), but as there is no corresponding Day1_Repeat value for line 107 (641), this Day1_Orig value would not be included in the new column.

5 REPLIES 5
txnelson
Super User

Re: how to select only those samples that meet two or more criteria

Here is how I would handle the issue

 

txnelson_0-1663882218911.png

x = .;
If( :SUBJID != Lag( :SUBJID ),
	If( Col Number( :SUBJID, :SUBJID, :VISIT ) == 1,
		x = :TiterGeoMean;
		:Day 1 Repeat = .;
	,
		:Day 1 Repeat = :TiterGeoMean;
		x = .;
	)
);
x;

 

Jim
dhagman
Level I

Re: how to select only those samples that meet two or more criteria

Jim, thanks for your suggestion, but it remains beyond my novice level of understanding and ability to execute.

jthi
Super User

Re: how to select only those samples that meet two or more criteria

Something like this might work (change column names):

If(Col Number(:O, :S) != 0 & Col Number(:R, :S),
	If(Col Cumulative Sum(!Is Missing(:O), :S) == 1,
		:O
	)
)

jthi_0-1663867639252.png

 

 

View more...
Names Default To Here(1);

dt = New Table("Untitled 3",
	Add Rows(6),
	New Column("S", Numeric, "Continuous", Format("Best", 12), Set Values([89, 89, 96, 96, 96, 96])),
	New Column("O", Numeric, "Continuous", Format("Best", 12), Set Values([641, ., 834, ., ., .])),
	New Column("R", Numeric, "Continuous", Format("Best", 12), Set Values([., ., ., 230, ., .]))
);

dt << New Column("Test", Numeric, Continuous, Formula(
	If(Col Number(:O, :S) != 0 & Col Number(:R, :S), /*check if both  and :R have value for this :S*/
		If(Col Cumulative Sum(!IsMissing(:O), :S) == 1, /* Check if row is first found value for  for this :S*/
			:O
		)
	);
));

 

 

-Jarmo
dhagman
Level I

Re: how to select only those samples that meet two or more criteria

Thank you, this works perfectly as long my dataset is sorted/organized such that the retest values always follow the originals. 

jthi
Super User

Re: how to select only those samples that meet two or more criteria

Seems to work fine for my simple test data but I might be missing something

jthi_1-1663954689276.png

 

 

-Jarmo