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
;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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