Hello,
I have a csv file that I'm working on that list members to a club. The data is very bad and I'm trying to clean it up. The first issue is that they put multiple people to one row using commas to seperate. So the fname field could have 1 or many commas. I want to take every field and leave it the same except for FName. For example
FName LName Address
Bob, Joe, William, Dave Jones 1234 Test St
There are many more variables but this is how I need the data to render
FName LName Address
Bob Jones 1234 Test St
Joe Jones 1234 Test St
William Jones | 1234 Test St |
Dave Jones | 1234 Test St |
Thank you for any help you can give me.
data have;
informat FName LName Address $50.;
input (FName LName Address) (&);
cards;
Bob, Joe, William, Dave Jones 1234 Test St
;
data want (drop=_:);
length FName $50;
set have (rename=FName=_FName);
_i=1;
do while (scan(_FName,_i,',') ne '');
FName=scan(_FName,_i,',');
output;
_i+1;
end;
run;
data have;
informat FName LName Address $50.;
input (FName LName Address) (&);
cards;
Bob, Joe, William, Dave Jones 1234 Test St
;
data want (drop=_:);
length FName $50;
set have (rename=FName=_FName);
_i=1;
do while (scan(_FName,_i,',') ne '');
FName=scan(_FName,_i,',');
output;
_i+1;
end;
run;
Hi Arthur,
Thank you so much. That worked perfectly.
You have been a great help to me and I truly appreciate it.
Thank you,
Jerry
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.