Count the number of occurrences of a set of character strings in the value of a character variable.
|Featured Step||DATA step|
|Featured Step Options and Statements||COUNT, COUNTC, and COUNTW functions|
Data set QUIZ_GRADES has quiz grades for four students. The grades are stored in one variable, QUIZ_STRING, and the grades are separated by commas.
QUIZ_GRADES Obs student quiz_string 1 431 B+,B-,A,I,A+ 2 501 A,A,B,P,C,U,F 3 289 A,A,B,A,A-,U 4 130 C+,B-,I,?,W
Output 9.16 QUIZ_SUMMARY Data Set
Example 9.16 QUIZ_SUMMARY Obs student quiz_string n_quizzes super good fair bad no_grades invalid 1 431 B+,B-,A,I,A+ 5 1 3 0 0 1 0 2 501 A,A,B,P,C,U,F ...