DATA Step, Macro, Functions and more

copy previous row multiple times

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

copy previous row multiple times

I have a question regarding copy rows multiple times in SET statement.

 

say, in Dataset 1, I hope each ID count adds up to 5 and copy ID in the next row

 

Dataset1:

ID          Count

123         2

456         1

 

Dataset 2 (result):

ID        Count

123      2

123      3

123      4

123      5

456      1

456      2

456      3

456      4

456      5


Accepted Solutions
Solution
‎10-18-2017 04:26 PM
Super User
Posts: 7,868

Re: copy previous row multiple times

data want;
set have;
do count = count to 5;
  output;
end;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎10-18-2017 04:26 PM
Super User
Posts: 7,868

Re: copy previous row multiple times

data want;
set have;
do count = count to 5;
  output;
end;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 71 views
  • 0 likes
  • 2 in conversation