BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

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;
2 REPLIES 2
andreas_lds
Jade | Level 19

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?

Kurt_Bremser
Super User
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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 811 views
  • 1 like
  • 3 in conversation