BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8

How to transform the below from

id   BU
1    Credit
2    Credit,Debit
3    Credit,Debit,Giftcard

 

To below:
id     BU
1    Credit
2    Credit
2    Debit
3    Credit
3    Debit
3    Giftcard

1 REPLY 1
ballardw
Super User

The basic approach I would take would be along these lines:

data want; 
   set have (rename=(bu=buold));
   do i=1 to countw(buold);
      bu = scan(buold,i);
      output;
   end;
   drop i buold;
run;

It would likely be a good idea to set a length for the BU variable to longest expected value but I don't know what that might be so leave it up to you.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 727 views
  • 0 likes
  • 2 in conversation