Hi
I have a table that looks like the following
User | Date | Code |
User1 | 5/1/15 | A918, A221, Y838, Y9222 |
User1 | 6/1/15 | A221, A922, T179, |
User2 | 7/1/15 | R104, J182, Z720 |
User3 | 7/1/15 | A831, N179, E1129, N185 |
User4 | 8/1/15 | A500 |
User4 | 9/1/15 | R104, A2970, E1172 |
I would like to split the column "Code" by the deliminator ',' to the follwing
User | Date | Code |
User1 | 5/1/15 | A918 |
User1 | 5/1/15 | A221 |
User1 | 5/1/15 | Y838 |
User1 | 5/1/15 | Y9225 |
User1 | 6/1/15 | A221 |
User1 | 6/1/15 | A922 |
User1 | 6/1/15 | T179 |
User2 | 7/1/15 | R104 |
User2 | 7/1/15 | J182 |
User2 | 7/1/15 | Z722 |
User3 | 7/1/15 | A831 |
User3 | 7/1/15 | N179 |
User3 | 7/1/15 | E1129 |
User3 | 7/1/15 | N188 |
User4 | 8/1/15 | A500 |
User4 | 9/1/15 | R104 |
User4 | 9/1/15 | A2970 |
User4 | 9/1/15 | E1174 |
In other words, the string i the column (Code) will need to be split by the deliminator and grouped by the coulmns (User) and (Date)
Any suggession is appreciated
Kind regards
Sorry, found the solulsion :
data NewSet;
set OldSet;
Old= Code;
do i= 1 to (countw(Old));
New = scan(Old, i,',');
output;
end;
drop i Old Code;
run;
Sorry, found the solulsion :
data NewSet;
set OldSet;
Old= Code;
do i= 1 to (countw(Old));
New = scan(Old, i,',');
output;
end;
drop i Old Code;
run;
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 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.