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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.