↧
Importing Data to Matrix that includes Dates and Charachters
↧
Avoid Table to Truncate Characters
Found it.
EViews has a limit of 1000 characters for an alpha series and your example above is cut-off exactly at 1000 characters. Because IMPORTTBL uses IMPORT internally, it is restricted by the same alpha series maximum character limit.
Perhaps you can use a shorter prefix name? (e.g. "p::" instead of "pnadc::")
Steve
EViews has a limit of 1000 characters for an alpha series and your example above is cut-off exactly at 1000 characters. Because IMPORTTBL uses IMPORT internally, it is restricted by the same alpha series maximum character limit.
Perhaps you can use a shorter prefix name? (e.g. "p::" instead of "pnadc::")
Steve
↧
↧
Importing Data to Matrix that includes Dates and Charachters
↧
Importing Data to Matrix that includes Dates and Charachters
↧
COM Automation Loop Error
Ok, I took a quick look at your Save_To_DB method and I have some concerns...
First, the way you call GetApplication with (ExistingOrNew) means it will try to connect to an existing EViews application if there is one already running. Then you call .Show to display the main EViews window. Finally, at the end of the function, you call .Run("exit") to ask EViews to quit.
There are a several reasons you don't want to do this. When you ask EViews to "exit" from your VBA program, EViews has to hide itself but then stick around until your VBA code decides to let go of the Application object (which it still has after calling app.Run("exit")). Because of this, EViews cannot immediately terminate when you call "exit". And with the nature of VBA, your app object won't get deleted and cleaned up (by the VBA garbage collector) until some time later -- meaning EViews will be sticking around for a while.
But since you're calling Save_To_DB in a loop, the function will get called again immediately and when you call GetApplication again, you might be connecting to the instance of EViews that was in the middle of trying to shut down. Now technically this shouldn't happen as an instance of EViews shutting down should not be keeping itself in the Windows COM registry, but the timing of how and when EViews removes itself from the COM registry can be tricky.
In any case, I have a few suggestions:
1. For the best performance, only use a single instance of EViews for all of your calls to Save_To_DB -- don't create and recreate EViews every time as this is very time consuming and uses a lot of resources. Instead, try just calling WFCLOSE at the end of the Save_To_DB function to close your workfile and leave EViews ready to run again for the next loop.
2. If you can't use a single instance, get a new instance of EViews (don't connect to existing instance) every time you run the Save_To_DB by calling .GetApplication(NewInstance). And if you do this, do not make the application visible and also do not call "EXIT" at the end. Simply leaving EViews hidden and then abandoning the app object at the end of your function will tell VBA that you don't need this instance anymore and EViews will shutdown on its own (as long as the window is hidden).
3. If you need to see the EViews window during execution, simply hide it at the end of the function by calling app.Hide (instead of calling app.Run("exit")).
Steve
First, the way you call GetApplication with (ExistingOrNew) means it will try to connect to an existing EViews application if there is one already running. Then you call .Show to display the main EViews window. Finally, at the end of the function, you call .Run("exit") to ask EViews to quit.
There are a several reasons you don't want to do this. When you ask EViews to "exit" from your VBA program, EViews has to hide itself but then stick around until your VBA code decides to let go of the Application object (which it still has after calling app.Run("exit")). Because of this, EViews cannot immediately terminate when you call "exit". And with the nature of VBA, your app object won't get deleted and cleaned up (by the VBA garbage collector) until some time later -- meaning EViews will be sticking around for a while.
But since you're calling Save_To_DB in a loop, the function will get called again immediately and when you call GetApplication again, you might be connecting to the instance of EViews that was in the middle of trying to shut down. Now technically this shouldn't happen as an instance of EViews shutting down should not be keeping itself in the Windows COM registry, but the timing of how and when EViews removes itself from the COM registry can be tricky.
In any case, I have a few suggestions:
1. For the best performance, only use a single instance of EViews for all of your calls to Save_To_DB -- don't create and recreate EViews every time as this is very time consuming and uses a lot of resources. Instead, try just calling WFCLOSE at the end of the Save_To_DB function to close your workfile and leave EViews ready to run again for the next loop.
2. If you can't use a single instance, get a new instance of EViews (don't connect to existing instance) every time you run the Save_To_DB by calling .GetApplication(NewInstance). And if you do this, do not make the application visible and also do not call "EXIT" at the end. Simply leaving EViews hidden and then abandoning the app object at the end of your function will tell VBA that you don't need this instance anymore and EViews will shutdown on its own (as long as the window is hidden).
3. If you need to see the EViews window during execution, simply hide it at the end of the function by calling app.Hide (instead of calling app.Run("exit")).
Steve
↧
↧
Non-Cholesky factorisation
The most concise way to recover the C matrix is to utilize the the coefficients that are saved in the "c" object of the workfile page when you run the var's "svar" procedure. Basically, you recreate the long-run pattern matrix shown in the SVAR results table, but include the estimated values. For example,
Less concise, and less numerically attractive, would be to calculate Ψ and multiply it by the estimated B matrix. The only advantage of that approach is that you don't need to reenter the pattern structure. If you find yourself needing to do a lot of these types of SVARs, it would probably be worthwhile to specify the long-run restrictions via a pattern matrix, e.g.,
and then write a subroutine that uses the pattern matrix and the "c" object to recover the C matrix.
Code:
matrix matc(4,4)
matc.fill c(1), c(2), c(3), c(4), 0, c(5), c(6), c(7), 0, 0, c(8), c(9), 0, 0, 0, c(10)
Less concise, and less numerically attractive, would be to calculate Ψ and multiply it by the estimated B matrix. The only advantage of that approach is that you don't need to reenter the pattern structure. If you find yourself needing to do a lot of these types of SVARs, it would probably be worthwhile to specify the long-run restrictions via a pattern matrix, e.g.,
Code:
matrix patc(4,4)
patc.fill na, na, na, na, 0, na, na, na, 0, 0, na, na, 0, 0, 0, na
and then write a subroutine that uses the pattern matrix and the "c" object to recover the C matrix.
↧
Importing Data to Matrix that includes Dates and Charachters
Not sure then how I would store character information in an array for a program to read sequentially in a loop. Any advice?? I need to do this for charachter and date data. Can it be done from a table??? I am able to import the data to a table object. Seems like a viable alternative - see my post in the 'Big Bond Table" thread, if you can. I have a program I started to outline there that shows what I am trying to do.
↧
Importing Data to Matrix that includes Dates and Charachters
↧
Huge Bond Data File - Filtering out Bonds I don't need
Not sure how to interpret your example, but if I am understanding the setup correctly, I think the easiest way is to perform the subsampling is to create a selection series and then to use a program to loop through the values you want to keep, setting the keep indicator to 1 whenever it encounters a value
(the for loop above needs to be in a program file). When you are do, you'll have KEEP with values of 1 for all of the matching CUSIPs and 0,s elsewhere.
Then
will filter the sample to only use those observations with CUSIP that matched the values in the loop.
Code:
smpl @all
series keep = 0
for %cuid 2 4 6 8
keep = @recode(cusip={%cuid}, 1, keep)
next
(the for loop above needs to be in a program file). When you are do, you'll have KEEP with values of 1 for all of the matching CUSIPs and 0,s elsewhere.
Then
Code:
smpl if keep=1
will filter the sample to only use those observations with CUSIP that matched the values in the loop.
↧
↧
Huge Bond Data File - Filtering out Bonds I don't need
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
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
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:
%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
↧
rtadf
Hi francescao,
Thanks!
As for your questions:
1. The GSADF is the sup of the BSADF used in Phillips, Shi and Yu (2015, IER)
2. The CV in the table is for the sup test, whereas the red line is the CV for the dates-tamping procedure. You can checkout PSY (2015) or the add-ins' user guide for elaborated explanations.
Good luck![Smile :)]()
Thanks!
As for your questions:
1. The GSADF is the sup of the BSADF used in Phillips, Shi and Yu (2015, IER)
2. The CV in the table is for the sup test, whereas the red line is the CV for the dates-tamping procedure. You can checkout PSY (2015) or the add-ins' user guide for elaborated explanations.
Good luck

↧
Huge Bond Data File - Filtering out Bonds I don't need
See, commands like this don't seem to work:
smpl dates_table(2,3) dates(3,3) IF tcusip=dates_table(2,1)
I thought it might be because the cell is stored as a string, so I tried this:
smpl @strdate(dates_table(2,3)) @strdate(dates_table(3,3)) IF tcusip=dates_table(2,1)
And this string to date function?
smpl @stod(dates_table(2,3)) @stod(dates_table(3,3)) IF tcusip=dates_table(2,1)
smpl dates_table(2,3) dates(3,3) IF tcusip=dates_table(2,1)
I thought it might be because the cell is stored as a string, so I tried this:
smpl @strdate(dates_table(2,3)) @strdate(dates_table(3,3)) IF tcusip=dates_table(2,1)
And this string to date function?
smpl @stod(dates_table(2,3)) @stod(dates_table(3,3)) IF tcusip=dates_table(2,1)
↧
Huge Bond Data File - Filtering out Bonds I don't need
↧
↧
Importing Data to Matrix that includes Dates and Charachters
Thank you Gareth. I am aware that a table can hold various forms of data. But the question was regarding reading the cell contents so that the information in the cell can be passed to a smpl function. This is the problem I am having. More detail is in the other thread, originally about filtering a large bond data file - I can't pass 861 cusips to one command, need to do it in a loop - can't hold dates in a matrix, need to do in a table. How do I get it to read table cells?
My posts here have some better detail: viewtopic.php?f=3&t=17662
My posts here have some better detail: viewtopic.php?f=3&t=17662
↧
Huge Bond Data File - Filtering out Bonds I don't need
Code:
%start = dates_table(2,3)
%end = dates_table(3,3)
smpl {%start} {%end}
I'll be honest, between this thread, your other thread and the emails you've sent, I have absolutely no idea what you're trying to achieve. But there is something somewhere that tells me you're making it far more complicated than it needs to be.
↧
Huge Bond Data File - Filtering out Bonds I don't need
Thank you. Ok, I see that with the braces I can specify the contents in a smpl statement.
The cusip and sample in the source file (undated irregular format) is going to change at every iteration in the loop - there are many bonds and many dates for each bond. Each bond starts on a different date.
My first question was "far too generic" as you said - the rest should have been more clear, sorry if I am confusing you. Trying to give you as much detail as possible. I have been a client for many years but I don't do a lot of data manipulation programming in EViews and I am not a professional programmer.
I took your code above and pasted into a program file and clicked run. This is the result.
Error in Sample: Illegal date 2/15/1983 in "SMPL 1983-02-15
1983-02-20".
Not trying to frustrate you, believe me. Just baffled by some of these issues. I posted my workfile, and will attach here again.
Again: what I am trying to do is create a daily workfile of bond data for "on-the-run" bonds - the most recently issued bond. Source data contains all bonds, which are issued frequently but irregularly. I want to track just the most recently issued bond at a give maturity. So I need to look up an issue date and the CUSIP identifier for that bond and copy the needed data from the giant source workfile to a new daily workfile for ONLY the dates that that bond was the MOST RECENTLY issued. Then, starting on the date a new bond is issued, I want to repeat the process and continue doing so until I have a nice set of time series with data for ONLY the "on-the-run" bonds. Basically, write bond data for bond x from date first issued until bond y is issued, then write data for bond y until bond z is issued, etc...
But I need to learn how to deal with this issue of getting EViews to read these dates. I'm sure it is a simple thing that I am making more difficult - but that is why I am asking.
The cusip and sample in the source file (undated irregular format) is going to change at every iteration in the loop - there are many bonds and many dates for each bond. Each bond starts on a different date.
My first question was "far too generic" as you said - the rest should have been more clear, sorry if I am confusing you. Trying to give you as much detail as possible. I have been a client for many years but I don't do a lot of data manipulation programming in EViews and I am not a professional programmer.
I took your code above and pasted into a program file and clicked run. This is the result.
Error in Sample: Illegal date 2/15/1983 in "SMPL 1983-02-15
1983-02-20".
Not trying to frustrate you, believe me. Just baffled by some of these issues. I posted my workfile, and will attach here again.
Again: what I am trying to do is create a daily workfile of bond data for "on-the-run" bonds - the most recently issued bond. Source data contains all bonds, which are issued frequently but irregularly. I want to track just the most recently issued bond at a give maturity. So I need to look up an issue date and the CUSIP identifier for that bond and copy the needed data from the giant source workfile to a new daily workfile for ONLY the dates that that bond was the MOST RECENTLY issued. Then, starting on the date a new bond is issued, I want to repeat the process and continue doing so until I have a nice set of time series with data for ONLY the "on-the-run" bonds. Basically, write bond data for bond x from date first issued until bond y is issued, then write data for bond y until bond z is issued, etc...
But I need to learn how to deal with this issue of getting EViews to read these dates. I'm sure it is a simple thing that I am making more difficult - but that is why I am asking.
↧
Huge Bond Data File - Filtering out Bonds I don't need
↧
↧
Huge Bond Data File - Filtering out Bonds I don't need
↧
Huge Bond Data File - Filtering out Bonds I don't need
↧
Huge Bond Data File - Filtering out Bonds I don't need
EViews Gareth wrote:Code:
%start = dates_table(2,3)
%end = dates_table(3,3)
smpl {%start} {%end}
I'll be honest, between this thread, your other thread and the emails you've sent, I have absolutely no idea what you're trying to achieve. But there is something somewhere that tells me you're making it far more complicated than it needs to be.
You are very adept at telling me that you don't understand what I am trying to do and charachterizing my efforts as making things more complicated than it needs to be - which is not helpful. But you don't tell me what it is you don't understand. You don't respond to my emails, but you are critical of my lack of detail publicly.
Communication issues are not resulting from my lack of detail. What don't you understand about what I am trying to do? I provided a lot of description, program outline, workfile, etc.
I've been working with EViews for 14 years and brought you a lot of business.
My other thread had the word matrix in the subject, four days later you tell me that dates can't be read to a matrix - despite days before telling me that "I just opened that file just fine."
I have spent a lot of time on this, much of it unnecessary as the original question was answered incorrectly. In other cases, questions are totally ignored. How many times does a user have to indicate that a suggested solution can't be performed on a list of 861 objects?
I would appreciate better support and if you have critical or derisive comments, you can send them in an email please. I am very polite and respectful to you. Your company has received a lot of money from me and university contracts to boot.
I am very frustrated with the support I have received in the past few days.
↧