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
;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.