One way for a report:
DATA WORK.Have;
FORMAT ID $5. Fave_Colors $10. Fave_Seasons $10. Fave_Songs $10.;
INFORMAT ID $5. Fave_Colors $10. Fave_Seasons $10. Fave_Songs $10.;
INPUT ID Fave_Colors Fave_Seasons Fave_Songs;
INFILE DATALINES DLM=':' DSD;
DATALINES;
12345:2,8:4:2,4,6
23456:1,3,7,9:1,3:1,2
34567:4,9:1,4:6
45678:1,8:2,3:3,7,8
56789:2:1:8,9
;
proc sort data=work.have;
by id;
run;
proc transpose data=work.have out=work.trans;
by id;
var fave_colors fave_seasons fave_songs;
run;
DATA WORK.temp ;
SET WORK.trans;
ValueCt=COUNTW(col1,',');
DO i=1 TO ValueCt;
value=SCAN(col1,i,',');
OUTPUT;
END;
RUN;
proc tabulate data=work.temp;
class _name_ value;
tables value='',
_name_=''*n=''
/ box="Value" misstext='0'
;
run;
Either a custom format for the _name_ variable or and assignment in work.temp might get nicer column headings in the final table.
Or separate tables for each original variable.
proc tabulate data=work.temp;
class _name_ value;
tables _name_,
value='',
n='Frequency'
/ box="Value" misstext='0'
;
label _name_='Topic';
run;
... View more