BookmarkSubscribeRSS Feed
rsva
Fluorite | Level 6

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.

1 REPLY 1
ballardw
Super User

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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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