Discussion:
How to repeat each row n times, where n is value in row ?
(too old to reply)
Ruud Steltenpool
2021-04-12 12:14:13 UTC
Permalink
In every row I have a Key, IndexXwithinKey, prop1, prop2, prop3, repetitionsNeeded

For every Key the repetitionsNeeded is the same, so for that Key the number of rows should go from Max(IndexXwithinKey) to times repetitionsNeeded that.

What's the easiest way?

And the most efficient?
Rich Ulrich
2021-04-12 20:35:42 UTC
Permalink
On Mon, 12 Apr 2021 05:14:13 -0700 (PDT), Ruud Steltenpool
Post by Ruud Steltenpool
In every row I have a Key, IndexXwithinKey, prop1, prop2, prop3, repetitionsNeeded
For every Key the repetitionsNeeded is the same, so for that Key the number of rows should go from Max(IndexXwithinKey) to times repetitionsNeeded that.
What's the easiest way?
And the most efficient?
I /think/ you are trying to create dummy records.

If the Maxrep in every record is a fixed value, you could
write a loop with the fixed value instead of the variable.
More generally -

For a record with Keyv, Lastseen, [some varlist], Maxrep -

Loop LineNo= Lastseen to Maxrep.
+xsave outfile= * /vars= Keyv to Maxrep, LineNo.
end loop.
exe.

Xsave does not count as a procedure, so you want to have
either the exe line or some procedure. I would probably be
interested in a FREQ on Lastseen.

There might be faster, easier, or more efficient ways to get
to whatever analysis or listing you are interested in, but this
is a quick solution to what I think you have asked.
--
Rich Ulrich
Loading...