BookmarkSubscribeRSS Feed
Dhana18
Obsidian | Level 7

I have a data set that has

IDCollDate1Specimen1TestType1Result1CollDate2Specimen2TestType2Result2CollDate3Specimen3TestType3Result3Treatment_Date1STDCDCRecTreatment1
17/31/2019PharyngealCultureNot Applicable (e.g. Culture positive for N. Meningitides)        
27/31/2019UrethralCultureGC Negative          
37/30/2019UrethralCultureGC Negative          
47/30/2019EndocervicalCultureGC Negative7/30/2019PharyngealCultureNot Applicable (e.g. Culture positive for N. Meningitides)  
57/30/2019EndocervicalCultureGC Negative          
67/30/2019UrethralCultureGC Negative          
77/30/2019UrethralCultureGC Negative          
87/30/2019UrethralCultureGC Negative          
97/30/2019PharyngealCultureGC Negative7/30/2019UrethralCultureGC Negative      
107/30/2019UrethralCultureGC Negative          
117/30/2019EndocervicalCultureGC Negative          
127/30/2019PharyngealGC nucleic acid amplification test (NAAT)GC Positive7/30/2019UrineGC nucleic acid amplification test (NAAT)GC Positive7/30/2019UrethralCultureGC Positive7/30/2019Ceftriaxone 250 mg IM in a single dose AND same day treatment with Azithromycin 1g orally in a single dose (Gonorrhea)
137/30/2019UrineGC nucleic acid amplification test (NAAT)GC Positive        8/1/2019Ceftriaxone 250 mg IM in a single dose AND same day treatment with Azithromycin 1g orally in a single dose (Gonorrhea)
147/30/2019UrineGC nucleic acid amplification test (NAAT)GC Positive7/30/2019PharyngealGC nucleic acid amplification test (NAAT)GC Positive7/30/2019UrethralCultureGC Positive7/30/2019Ceftriaxone 250 mg IM in a single dose AND same day treatment with Azithromycin 1g orally in a single dose (Gonorrhea)
157/30/2019UrineGC nucleic acid amplification test (NAAT)GC Positive7/30/2019UrethralCultureGC Positive    7/30/2019Ceftriaxone 250 mg IM in a single dose AND same day treatment with Azithromycin 1g orally in a single dose (Gonorrhea)
167/29/2019UrethralCultureGC Positive        7/29/2019Ceftriaxone 250 mg IM in a single dose AND same day treatment with Azithromycin 1g orally in a single dose (Gonorrhea)
177/29/2019UrethralCultureGC Positive        7/29/2019Ceftriaxone 250 mg IM in a single dose AND same day treatment with Azithromycin 1g orally in a single dose (Gonorrhea)
187/29/2019RectalCultureGC Negative7/29/2019PharyngealGC nucleic acid amplification test (NAAT)GC Negative7/29/2019UrethralCultureGC Negative 
197/29/2019PharyngealCultureNot Applicable (e.g. Culture positive for N. Meningitides)        
207/29/2019EndocervicalCultureGC Negative          
217/29/2019UrethralCultureNot Applicable (e.g. Culture positive for N. Meningitides)        
227/29/2019EndocervicalCultureGC Negative          

 

I would like to know number of tests conducted for each ID and number of Spe collected and number of pos result for each ID. How do i create a separate column of number of spe number of tests and number of pos result by specimen.

Also i would like to get time frame between positive test and treatment date.

Please help

1 REPLY 1
Shmuel
Garnet | Level 18

Try next code and adapt it to your request:

data temp;
 set have;
       keep ID Colldate1 Sprcimen1 TestTye1 Result1;
       output;  /* left test */
       if not missing (colldate2) then do;
           colldtae1 = colldate2; 
           specimen1 = specimen2;
           testtype1 = testtype2;
          result1 = result2;
          output;
       end;
run;

Now it is easy to count using proc freq or any other method.:

 

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
  • 291 views
  • 0 likes
  • 2 in conversation