BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am trying to get a count of comorbidities for each patient. I have a variable that is a list of comorbidities seperated by commas. Is there a way to count the commas in the field? Or would you advise splitting them into multiple variables? The most anyone has is 11 comorbidities.

Sample:
Sleep apnea,Lichen planus,IBS,RAD,Multinodular thyroid,Actinic keratosis,Neuropathy
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Have a look at the COUNT function.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

count words site:sas.com
art297
Opal | Level 21
Vanessa,

If there is a chance that some records don't have any comorbidities, you could do something like the following:

data have;
informat comorbidities $255.;
infile cards truncover;
input comorbidities &;
i=1;
count=0;
do while (not(missing(scan(comorbidities,i,','))));
i+1;
count+1;
end;
cards;
Sleep apnea,Lichen planus,IBS,RAD,Multinodular thyroid,Actinic keratosis,Neuropathy
Sleep apnea,Lichen planus,IBS

test
;

HTH,
Art

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1026 views
  • 0 likes
  • 3 in conversation