DATA Step, Macro, Functions and more

split up and create copies

Accepted Solution Solved
Reply
Frequent Contributor
Frequent Contributor
Posts: 79
Accepted Solution

split up and create copies

[ Edited ]

Hello,

I have a quick question

 

I have a table  which looks like below

 

SEQ MODE TYPE   assign_value

1        m          x           a, axau

1        m         y            a,axau

1        m          z          m, x, n

 

.....

 

I would like to get the following such that assignvalue which is separated by commas creates a duplicate row for each assign_value value which is separated by commas

 

SEQ MODE TYPE   assign_value

1        m          x           a

1        m          x           axau

1        m         y            a

1        m         y            axau

1        m          z          m

1        m          z          x

1        m          z          n

.....

 

many thanks for your help

 


Accepted Solutions
Solution
‎05-24-2017 05:09 PM
Super User
Super User
Posts: 7,942

Re: split up and create copies

Hi,

 

data want (drop=i old);
  set have (rename=(assign_value=old));
  length assign_value $100;
  do i=1 to countw(old,",");
    assign_value=scan(old,i,",");
    output;
  end;
run;

View solution in original post


All Replies
Solution
‎05-24-2017 05:09 PM
Super User
Super User
Posts: 7,942

Re: split up and create copies

Hi,

 

data want (drop=i old);
  set have (rename=(assign_value=old));
  length assign_value $100;
  do i=1 to countw(old,",");
    assign_value=scan(old,i,",");
    output;
  end;
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 154 views
  • 1 like
  • 2 in conversation