DATA Step, Macro, Functions and more

Splitting one records into multiple records

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Splitting one records into multiple records

Could you help me to solve the following question?

 

name  count

abc       2

cde       3

def        1

......

xyz       5

 

the result I want is the following

name

abc

abc

cde

cde

cde

def

....

xyz

xyz

xyz

xyz

xyz


Accepted Solutions
Solution
‎02-22-2017 05:55 PM
Valued Guide
Posts: 2,175

Re: Splitting one records into multiple records

Data want( keep= name ) ;
Set have ;
Do i= 1 to count ;
Output;
End ;
Run ;

View solution in original post


All Replies
New Contributor
Posts: 3

Splitting one row record into Multiple records rows

Could you help me to solve the following question?

 

name  count

abc       2

cde       3

def        1

......

xyz       5

 

the result I want is the following

name

abc

abc

cde

cde

cde

def

....

xyz

xyz

xyz

xyz

xyz

 

PROC Star
Posts: 290

Re: Splitting one row record into Multiple records rows

 

data want;

    set have;

   do i = 1 to count;

       output;

   end;

run;

 

 

Super User
Posts: 17,961

Re: Splitting one row record into Multiple records rows

Just a note that there is no need to post in multiple forums. Since you have an answer in this post, I've merged your other, identical question, with this post. 

Solution
‎02-22-2017 05:55 PM
Valued Guide
Posts: 2,175

Re: Splitting one records into multiple records

Data want( keep= name ) ;
Set have ;
Do i= 1 to count ;
Output;
End ;
Run ;
New Contributor
Posts: 3

Re: Splitting one records into multiple records

thank you Peter!
Valued Guide
Posts: 2,175

Re: Splitting one records into multiple records

If this is the answer you wanted, please mark it as the solution
PROC Star
Posts: 7,366

Re: Splitting one records into multiple records

@Peter_C: Hi Peter!  It was marked as a solution almost immediately after you posted it. I know, because I had posted basically the same solution seconds after you did, saw yours, thus delteted mine.

 

Art, CEO, AnalystFinder.com

Valued Guide
Posts: 2,175

Re: Splitting one records into multiple records

Apols
This browser dod not make that clear
☑ This topic is solved.

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

Discussion stats
  • 8 replies
  • 168 views
  • 1 like
  • 5 in conversation