BookmarkSubscribeRSS Feed
Dhana18
Obsidian | Level 7
I have a data set like this 
IncidentID CollDate_1 Specimen_1 TestType_1 Result_1 F G H 
1 3313025 11/10/2017 Pharyngeal GC nucleic acid amplification test (NAAT) GC Negative       
2 3325056 04/13/2018 Pharyngeal Culture GC Negative       
3 3443578 10/02/2018 Rectal Culture GC Negative       
4 3325011 04/23/2018 Urine GC nucleic acid amplification test (NAAT) GC Negative       
5 2699874 04/24/2017 Urethral Culture GC Positive       
6 3312054 10/27/2017 Urine GC nucleic acid amplification test (NAAT) GC Negative       
7 3614671 03/26/2019 Urethral Culture GC Negative       
8 2719247 05/17/2017 Pharyngeal Culture Not Applicable (e.g. Culture positive for N. Meningitides)       
9 2990718 12/06/2017 Pharyngeal Culture GC Negative       
10 3439067 10/23/2018 Urethral Culture Not Applicable (e.g. Culture positive for N. Meningitides)       
11 3339024 09/18/2018 Urethral Culture GC Negative       
12 3296006 07/05/2017 Urethral Culture Not Applicable (e.g. Culture positive for N. Meningitides)       
13 2935129 10/12/2017 Pharyngeal GC nucleic acid amplification test (NAAT) GC Negative       
14 3100853 02/19/2018 Urine GC nucleic acid amplification test (NAAT) GC Positive       
15 3576407 03/28/2019 Urine GC nucleic acid amplification test (NAAT) GC Positive       
16 3330966 06/14/2018 Urethral Culture GC Negative       
17 3325029 04/13/2018 Urine GC nucleic acid amplification test (NAAT) GC Negative       
18 3497934 01/15/2019 Endocervical Culture GC Positive       
19 2842778 08/22/2017 Urine GC nucleic acid amplification test (NAAT) GC Negative       
20 3328919 03/26/2018 Pharyngeal Culture GC Negative       

I used this code to create the test and result.


Data Labtests.July1719_Test1;
set Labtests.July1719_Tests;
if Specimen_1="Pharyngeal" AND TestType_1="GC nucleic acid amplification test (NAAT)" AND Result_1="GC Negative" then NAATP="Neg";
if Specimen_1="Pharyngeal" AND TestType_1="GC nucleic acid amplification test (NAAT)" AND Result_1="GC Positive" then NAATP="Pos";
if Specimen_1="Pharyngeal" AND TestType_1="Culture" AND Result_1="GC Negative" then CULP="Neg";
if Specimen_1="Pharyngeal" AND TestType_1="Culture" AND Result_1="GC Positive" then CULP="Pos";
if Specimen_1="Pharyngeal" AND TestType_1="Culture" AND Result_1="Not Applicable (e.g. Culture positive for N. Meningitides)" then NONGCP="Pos";
if Specimen_1="Rectal" AND TestType_1="GC nucleic acid amplification test (NAAT)" AND Result_1="GC Negative" then NAATR="Neg";
if Specimen_1="Rectal" AND TestType_1="GC nucleic acid amplification test (NAAT)" AND Result_1="GC Positive" then NAATR="Pos";
if Specimen_1="Rectal" AND TestType_1="Culture" AND Result_1="GC Negative" then CULR="Neg";
if Specimen_1="Rectal" AND TestType_1="Culture" AND Result_1="GC Positive" then CULR="Pos";
if Specimen_1="Rectal" AND TestType_1="Culture" AND Result_1="Not Applicable (e.g. Culture positive for N. Meningitides)" then NONGCR="Pos";
if Specimen_1="Urine" AND TestType_1="GC nucleic acid amplification test (NAAT)" AND Result_1="GC Negative" then NAATUR="Neg";
if Specimen_1="Urine" AND TestType_1="GC nucleic acid amplification test (NAAT)" AND Result_1="GC Positive" then NAATUR="Pos";
if Specimen_1 in("Urethral", "Endocervical" , "Vaginal") AND TestType_1="GC nucleic acid amplification test (NAAT)" AND Result_1="GC Negative" then NAATG="Neg";
if Specimen_1 in("Urethral", "Endocervical" , "Vaginal") AND TestType_1="GC nucleic acid amplification test (NAAT)" AND Result_1="GC Positive" then NAATG="Pos";
if Specimen_1 in("Urethral", "Endocervical" , "Vaginal") AND TestType_1="Culture" AND Result_1="GC Negative" then CULG="Neg";
if Specimen_1 in("Urethral", "Endocervical" , "Vaginal") AND TestType_1="Culture" AND Result_1="GC Positive" then CULG="Pos";
if Specimen_1 in("Urethral", "Endocervical" , "Vaginal") AND TestType_1="Culture" AND Result_1="Not Applicable (e.g. Culture positive for N. Meningitides)" then NONGCG="Pos";
RUN;

The result is like this.
IncidentID	CollDate_1	Specimen_1	TestType_1	Result_1	NAATP	CULP	NONGCP	NAATR
1	11/10/2017	Pharyngeal	GC nucleic acid amplification test (NAAT)	GC Negative		Neg		
2	4/13/2018	Pharyngeal	Culture	GC Negative			Neg	
3	10/2/2018	Rectal	Culture	GC Negative				
4	4/23/2018	Urine	GC nucleic acid amplification test (NAAT)	GC Negative				
5	4/24/2017	Urethral	Culture	GC Positive				
6	10/27/2017	Urine	GC nucleic acid amplification test (NAAT)	GC Negative				
7	3/26/2019	Urethral	Culture	GC Negative				
8	5/17/2017	Pharyngeal	Culture	Not Applicable (e.g. Culture positive for N. Meningitides)				Pos
9	12/6/2017	Pharyngeal	Culture	GC Negative			Neg	
10	10/23/2018	Urethral	Culture	Not Applicable (e.g. Culture positive for N. Meningitides)				
11	9/18/2018	Urethral	Culture	GC Negative				
12	7/5/2017	Urethral	Culture	Not Applicable (e.g. Culture positive for N. Meningitides)				
13	10/12/2017	Pharyngeal	GC nucleic acid amplification test (NAAT)	GC Negative		Neg		
14	2/19/2018	Urine	GC nucleic acid amplification test (NAAT)	GC Positive				
15	3/28/2019	Urine	GC nucleic acid amplification test (NAAT)	GC Positive				
16	6/14/2018	Urethral	Culture	GC Negative				
17	4/13/2018	Urine	GC nucleic acid amplification test (NAAT)	GC Negative				
18	1/15/2019	Endocervical	Culture	GC Positive				
19	8/22/2017	Urine	GC nucleic acid amplification test (NAAT)	GC Negative				
20	3/26/2018	Pharyngeal	Culture	GC Negative			Neg	
I  am happy with the result table above BUT the question is I have more than one test per incident they are similar test (NAATU, NAATR etc)  like I have here in the result table above.  I want other tests and result to appear in the same column I already have in the result table above. All test per incident should appear in one row. Please pleas eehlp i am under tremendous pressure to complete this task by due date.  Thank you.
2 REPLIES 2
PaigeMiller
Diamond | Level 26

Would you do us all a favor? Would you please type the text of your questions outside of (not inside of) a text box (the {i} icon) or code box (the running man icon)? Only code or SAS Logs should be in a text box or code box. Actual questions do not go in a text box or code box.

 

The way you have type your question inside a text box or code box, it doesn't word wrap and it is very difficult to read.

--
Paige Miller
ballardw
Super User

You say something about all of the results appearing in the same column.

Can you show an example of the desired output that shows what you mean as there are likely several interpretations and most of them are extremely difficult to do anything except print.

 

Just show an Id and examples of multiple test results. Since you have extremely long text values for your variables including any number of those will just make it difficult to read the intended results.

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
  • 2 replies
  • 645 views
  • 0 likes
  • 3 in conversation