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 set that has

ID spe1 test1 result1  spe2 test2 result2 spe3 test3 result3 spe4 test4 result4 spe5 test5 result5 spe6 test6 result6 spe7 test7 result7

1  ur      cul    neg       thr    cul     pos      rec    Nat    neg

2 ur      cul    neg       rec    Nat    neg

3 thr      cul    pos     

4 ur      cul    neg        rec    Nat    neg        thr    cul     pos 

5 rec      cul    pos       thr    cul     pos      

6 rec    Nat    neg        ur      cul    neg       thr    cul     pos      rec    Nat    neg 

7 rec    Nat    pos      ur      cul    neg       thr    cul     pos      cvx    Nat    neg

7 rec    Nat    pos      ur      cul    neg       thr    cul     pos      cvx    Nat    neg   urt      cul    neg

 

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 speciemn

Please help

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

Please post the result you expect from the data you have posted.

The function cmiss returns the number of variables with missing value. If the number of variables is always 7, something like

count_spe = 7 - cmiss(of spe1-spe7);

should give you the number you want.

View solution in original post

3 REPLIES 3
andreas_lds
Jade | Level 19

Please post the result you expect from the data you have posted.

The function cmiss returns the number of variables with missing value. If the number of variables is always 7, something like

count_spe = 7 - cmiss(of spe1-spe7);

should give you the number you want.

Dhana18
Obsidian | Level 7
Thank you! thank you!
I got the column of what I want that are count of Specimen count of tests and count of result.
Now i would like to get results by specimen. for example a patient had 3 different tests of those three tests how many results are positive and positive from what specimen. Please help
PaigeMiller
Diamond | Level 26

If you are creating this data set, and you have a choice, I would create it vertically rather than horizontally. This makes most analyses much simpler, and probably can be done using PROC FREQ.

 

Something like this:

 

ID     SEQUENCE             SPE         TEST          RESULT
1       1                   ur          cul           neg
1       2                   thr         cul           pos

Even better yet, result could be 0 (negative) or 1 (positive) instead of neg or pos.

 

If you are receiving the data in the wide format you showed, I would make the effort to transpose it to the long format to make things easier.

--
Paige Miller

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