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;

 

 

sas-innovate-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 276 views
  • 0 likes
  • 1 in conversation