Thank you very much. I see the logic of the code above. Thanks Glenn.
as long as the line "for %cuid 2 4 6 8" would handle 861 cusips, but I don't think it will based on my experimentation.
So I believe filtering the data is not as important.
What I want to do now, as in the program, is to do the algorithm that filters the huge data set down to one single cusip for the desired date range based on data from a table (as in text file in workfile).
My program needs to take my large unstructured workfile, filter it down to the specified date ranges for a single cusip number - one at a time in a loop - and copy the data to another workfile. Then, in the loop, go back to sample @all and then resample down to the next cusip date range combination and copy that data to the new workfile, and keep doing until all the data is sent to the new workfile.
The program would be pulling the cusip and dates from the cells of a table (as dates/charachters in a matrix are problematic).
If I could store dates in a matrix, the first CUSIP I want is in the first row and first column. I was calling the matrix 'dates' - so in the program
CUSIP Ann_Date Issue_Date
8DIGITS1 1983-02-13 1983-02-15
8DIGITS2 1983-02-18 1983-02-20
8DIGITS3 1983-03-01 1983-03-03
8DIGITS4 1983-03-10 1983-03-12
Code: Select all
%startdate="1983-01-01" 'set prior to first auction (for future WI data) purposes
%enddate="1983-06-01"
wfcreate d5 %startdate %enddate
'Matrix called dates holds arrays of information needed
'First column of matrix holds CUSIP identifiers
'Third column of matrix holds Issue_Dates
'copying data from test_dates to new workfile in specified date range
'for loop (need help here)
for !i=1 to @nrows(dates) 'see what I am trying to do? 4 rows in the matrix
smpl dates(i,3) dates(i+1,3) IF tcusip = dates(i,1) 'so sample from 1983-02-15 to 1983-02-20 IF tcusip="8DIGITS"
'below I need help referencing the new workfile - do my code might not make sense (please advise on how to specify workfiles)
series tcusip (in new workfile) = tcusip (test_dates)
series tdbid (in new workfile) = tdbid (test_dates)
series tdask (in new workfile) = task (test_dates) 'etc...
'here I can add more series once it gets working - but this is the gist
smpl @all 'set back to full sample before returning to repeat in loop for next CUSIP
'*** at this point it should loop back to do the same for the following bond 8DIGITS2
'when it gets to the last cusip, I would then have it fill data to @last
So because I have to use a table, rather than a matrix. The data for the first CUSIP is shifted down one row - no big deal. But how do I change the code to reference a table cell?
Also, as you can see, I am using two workfiles in one program. Source file is undated and irregular (but has date columns), target files is a dated daily 5-day workfile.
Source file looks like this (notice, data for first CUSIP extends beyond issue date of second CUSIP - this is why I need specific ranges for each CUSIP):
8DIGITS1 1983-02-13 99.5 99.4375
8DIGITS1 1983-02-14 99.59375 99.53125
8DIGITS1 1983-02-15 99.71875 99.65625
8DIGITS1 1983-02-16 99.5625 99.5
8DIGITS1 1983-02-17 99.8125 99.75
8DIGITS1 1983-02-18 99.6875 99.625
8DIGITS1 1983-02-19 99.34375 99.28125
8DIGITS1 1983-02-20 99.28125 99.21875
8DIGITS1 1983-02-21 99.28125 99.21875
8DIGITS1 1983-02-22 99.28125 99.21875
8DIGITS1 1983-02-23 99.3125 99.25
8DIGITS2 1983-02-18 99.15625 99.09375
8DIGITS2 1983-02-19 99.0625 99
8DIGITS2 1983-02-20 99.21875 99.15625
8DIGITS2 1983-02-21 98.875 98.8125
8DIGITS2 1983-02-22 98.09375 98.03125
8DIGITS2 1983-02-23 98.3125 98.25
8DIGITS2 1983-02-24 97.90625 97.84375
8DIGITS2 1983-02-25 97.90625 97.84375
8DIGITS2 1983-02-26 97.96875 97.90625
8DIGITS2 1983-02-27 98.15625 98.09375
8DIGITS2 1983-02-28 97.8125 97.75
8DIGITS2 1983-03-01 97.84375 97.78125
I think I am pretty close to making a usable program. I just need advice on how to adapt it.
Please help. I very much appreciate this...
Cheers,
Jim