/********************************************************************** * create a dictionary from a variable of strings * Peng Zeng * 07-25-2019 **********************************************************************/ data texts; input str $1-80; datalines; One of the advantages.of the SAS/IML matrix language, Notice that the delimiters! do not ... include ; proc print data = texts; run; data dictionary_raw; length word $20; set texts; delims = ' ,.!'; numWords = countw(str, delims); /* count number of words */ do i = 1 to numWords; word = scan(str, i, delims); /* extract i-th word */ output; end; run; proc print data = dictionary_raw; run; proc sql; create table dictionary as select distinct upcase(word) as word from dictionary_raw order by word; quit; proc print data = dictionary; run; /********************************************************************** * THE END **********************************************************************/