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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 2 replies
  • 692 views
  • 0 likes
  • 3 in conversation