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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 587 views
  • 0 likes
  • 3 in conversation