Greetings,
I have a data with 5 columns for each partner, test results for each partner (POS1-POS5 if positive, NEG1-5 for negative results). Te last set of columns is age group of that partner. Snap shot of my data below.
Partner1 | Partner2 | Partner3 | Partner4 | Partner5 | POS1 | POS2 | POS3 | POS4 | POS5 | NEG1 | NEG2 | NEG3 | NEG4 | NEG5 | Age1 | Age2 | Age3 | Age4 | Age5 |
1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 10-15 | 10-15 | 16-20 | 21-25 | 50+ |
1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 16-20 | 21-25 | 50+ | 10-15 | 10-15 |
1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 21-25 | 50+ | 10-15 | 50+ | 50+ |
1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 10-15 | 10-15 | 16-20 | 21-25 | 50+ |
I am trying to create a count of how POS and Neg by age group.
e.g.If there is
1 partner with age A1 then #A1=1, A2=0, A3=0, A4=0
2 partners with A1 and A3 then #A1=2, A2=0, A3=1, A4=0
3 partners with A1, A3, A4 then #A1=3, A2=0, A3=2, A4=1
4 partners with 2 in A1, 2 in A4 then #A1=5, A2=0, A3=2, A4=3
Snapshot of my final output:
POS | NEG | |
Age1 | ||
Age2 | ||
Age3 | ||
Age4 |
I used SUM (of POS1-POS5) and SUM (of NEG1-Neg5) to get no. of positives and negatives. But not sure how to proceed with POS and NEGs by age group.
THanks in Advance.
Just how does this differ from your other extremely similar question in
https://communities.sas.com/t5/SAS-Programming/Get-counts-by-groups-across-columns/m-p/748548
And have you read any of the responses to that one and asked questions if you didn't understand.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.