Hello
The data set contain 3 variables: Customer ID, transfer description, amount.
transfer description is a char variable.
Each customer ID can have multiple rows.
I want to do the following :
Find the frequency distribution of separate words from field "transfer description"
data have;
informat transfer_description $5000.;
input ID transfer_description amount;
infile datalines delimiter='|';
datalines;
111|Transfer to my friend Joe Kaplan|1000
111|Salary IBM|2000
111|Salary WIZZ|3980
111|Transfer to my father|500
333|Transfer to my gf|4000
333|Son help|3000
222|Salary IBM|1500
222|Charity|2500
222|Charity|3000
222|transfer to my friend Jula|8000
;
Run;
Seems to be dealing with the same problem as https://communities.sas.com/t5/SAS-Programming/split-char-into-multiple-columns-and-then-append-the-...
Do you want the frequencies by id?
data long;
set have;
length desc $20; /* set sufficient length as needed */
do i = 1 to countw(transfer_description," ");
desc = scan(transfer_description,i," ");
output;
end;
keep desc;
run;
proc freq data=long;
tables desc;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.