I have a data like this
PatientId Test A Test B Test C Test D
1 0 1 1 0
2 0 0 0 1
3 0 1 0 0
4 1 0 0 1
5 1 1 1 0
6 0 0 0 1
7 1 1 0 0
8 0 0 0 1
9 0 1 1 0
10 0 0 0 1
11 0 1 0 0
I would like to know if patient is positive(1) in more than on test. how do i need to code?
Please help
With your data and assuming the Test.. variables are numeric and only have values of missing, 0 or 1 something like below should work.
data sample;
infile datalines dlm=' ' truncover;
input PatientId Test_A Test_B Test_C Test_D;
outcome_flg= sum(of test_:) > 1;
datalines;
1 0 1 1 0
2 0 0 0 1
3 0 1 0 0
4 1 0 0 1
5 1 1 1 0
6 0 0 0 1
7 1 1 0 0
8 0 0 0 1
9 0 1 1 0
10 0 0 0 1
11 0 1 0 0
;
With your data and assuming the Test.. variables are numeric and only have values of missing, 0 or 1 something like below should work.
data sample;
infile datalines dlm=' ' truncover;
input PatientId Test_A Test_B Test_C Test_D;
outcome_flg= sum(of test_:) > 1;
datalines;
1 0 1 1 0
2 0 0 0 1
3 0 1 0 0
4 1 0 0 1
5 1 1 1 0
6 0 0 0 1
7 1 1 0 0
8 0 0 0 1
9 0 1 1 0
10 0 0 0 1
11 0 1 0 0
;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.