Dear Community
I’m looking for a program for the following.
What I have is a table HAVE. It has 3 fields: CD_YEAR, CD_MONTH, var_A.
This table contains 50 records:
The first 20 records are all CD_YEAR = 2018 and CD_MONTH = 1
The next 30 records are all CD_YEAR = 2018 and CD_MONTH = 2
What I need is a table WANT, where for var_A, a value is filled in following a statistical distribution.
I’m simplifying here: let’s say the distribution is:
50% => var_A = 10
25% => var_A = 15
25% => var_A = 20
So in table WANT, the needed result is:
First 10 records (cd_year= 2018, cd_month = 1) => var_A = 10
Next 5 records (cd_year= 2018, cd_month = 1) => var_A = 15
Next 5 records (cd_year= 2018, cd_month = 1) => var_A = 20
Next 15 records (cd_year= 2018, cd_month = 2) => var_A = 10
Next 7 or 8 records (cd_year= 2018, cd_month = 2) => var_A = 15
Next 7 or 8 records (cd_year= 2018, cd_month = 2) => var_A = 20
Notice the last 2 lines here above: as 25% of 30 records is not a whole number (7,5), it should take 7 or 8 records for var_A = 15. By consequence, it should take resp. 8 or 7 records for var_A = 20.
I hope I explained it clearly enough so that anyone could understand what I want.
I can’t see a method how to implement this.
Any hints or directions how to deal with this would be very appreciated.
(the real distribution is a little more complicated, with 13 percentages - I used the above example just to illustrate)
Thanks
... View more