Page 1 of 1
Generate special series problem
Posted: Tue Jun 13, 2017 12:54 pm
by karakilamaravilla
Hi,
I need help creating a program that generates the following series:
-> My database is composed of 84 series of SKUs each containing 114 rows.
-> And 84 series of DemandaSKU that also contain 114 rows.
What I need is to generate a matrix (114,84) that in the fields has the following number:
The sum of how many rows in demandasku fit in stock?
Example: For row 1 of sku1 what is the number of rows of demandasku summed up to the value of row 1 sku1?
Re: Generate special series problem
Posted: Tue Jun 13, 2017 2:04 pm
by EViews Matt
Hello,
Some clarification is needed. When you say "number of rows of demandasku summed up", do you mean initial rows, i.e., always start summing a column of demandasku from row 1?
Re: Generate special series problem
Posted: Tue Jun 13, 2017 2:41 pm
by karakilamaravilla
Hello,
Some clarification is needed. When you say "number of rows of demandasku summed up", do you mean initial rows, i.e., always start summing a column of demandasku from row 1?
Dear,
As an example,
For SKU1 row 1: How many rows of DemandSKU1 (from row 1 to row) add at most the amount of row 1 of SKU1.
For SKU1 row 2: How many rows of DemandSKU1 (from row 2 through n) add at most the amount of row 2 of SKU1.
N depends on when the target is reached in the sum.
Re: Generate special series problem
Posted: Tue Jun 13, 2017 4:17 pm
by EViews Matt
I believe the following generates the first column of the results matrix you want (which I've called m). You can double check the results and generalize the code to all columns.
Code: Select all
matrix(@obsrange, 1) m
for !i = 1 to @obsrange
%smpl = @str(!i) + " " + @str(@obsrange)
series tmp = @cumsum(demandasku1, %smpl) <= @elem(sku1, !i)
m(!i, 1) = @sum(tmp)
next
Re: Generate special series problem
Posted: Tue Jun 13, 2017 7:08 pm
by karakilamaravilla
Dear Matt,
Your response was 100% satisfactory. How can I close the question, I am new here in this forum.
Thank you very much for your help.
Re: Generate special series problem
Posted: Wed Jun 14, 2017 8:43 am
by EViews Matt
I'm glad that worked for you. There's no procedure for closing threads in this forum, they remain open for future inquiries from anyone.