BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ammarhm
Lapis Lazuli | Level 10

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

1 ACCEPTED SOLUTION

Accepted Solutions
ammarhm
Lapis Lazuli | Level 10

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;

 

 

View solution in original post

1 REPLY 1
ammarhm
Lapis Lazuli | Level 10

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;

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1 reply
  • 674 views
  • 0 likes
  • 1 in conversation