Hello,
In my dataset each person (eventID) is associated with 1-3 pathogens (pathogenSeq). I want to look at the total counts of each of the pathogens, but some people have tested with more than 1 pathogen. How would I make it so that if a person has multiple pathogens they are counted for each pathogen?
Here is what I tried per my teacher's advice but the output is blank:
proc sort data=infection;
by eventID pathogenSeq; run;
data infection2;
set infection;
if first.pathogenSeq = 1 then count = 0;
count = count + 1;
if last.pathogenSeq = 1 then output;
retain count; run;
Would it make more sense to create a new variable for pathogen? Any help is appreciated, thanks!
I added a BY statement and did not receive any error messages.
How would you recommend I verify the procedure worked properly?
Maybe:
proc summary data=have nway;
class pathogenSeq;
output out=counted(drop= _type_ rename=(_freq_ = count));
run;
If this doesn't work, please post example data in usable form together with the expected result.
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!
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.