BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dhana18
Obsidian | Level 7
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
			
          
1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

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
;

View solution in original post

1 REPLY 1
Patrick
Opal | Level 21

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
;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 639 views
  • 0 likes
  • 2 in conversation