I’ve seen a lot of ugly ways to count the number of words in a comma separated list, most of them involve an overly complicated macro. There is an easier way. Just add a field to your table, then you want to use the LENGTH function to count your comma separated list, and the LENGTH and COMPRESS function to count the string with your commas removed. This will give you the number of words in the list:

data temp_stuff;

set temp_stuff;

list_count = length(comma_list)-length(compress(comma_list,”,”));