fetching data from bloomberg
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
fetching data from bloomberg
Hi - I am fetching some data from bloomberg using the following syntax:
dbopen(type=bloom) curncy
'fetching data
fetch <ticker names>...
I see that it is pulling the data for everyday and leaves the cells blank if there is no data for that day - as such I have time series of equal length but with each having some missing data points. What is the command in the code to say if there is no data for that date take the reading from the day before? I need my time series to be complete (ie a data point for each day) and of equal length
Thanks
dbopen(type=bloom) curncy
'fetching data
fetch <ticker names>...
I see that it is pulling the data for everyday and leaves the cells blank if there is no data for that day - as such I have time series of equal length but with each having some missing data points. What is the command in the code to say if there is no data for that date take the reading from the day before? I need my time series to be complete (ie a data point for each day) and of equal length
Thanks
Re: fetching data from bloomberg
actually in my previous post I need some statement that says if no data is available on any given date then take the last available data point for that date (as opposed to specifying the day before - as there may be no available data for the day before either). Thanks.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: fetching data from bloomberg
You can't do it on the fetch, but you can do it after the fact. by generating into a new series. I think this should work:
[edit] This assumes that the first observation for the original Y is valid.
Code: Select all
smpl @all
yadj = @recode(y=na, y(-1), y)
Re: fetching data from bloomberg
Great thanks Glenn - it works with the arguments the other way round. thanks for the help
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: fetching data from bloomberg
Actually that last one needs to be modified a bit to handle multiple missings in a row
Code: Select all
smpl @first @first
series yadj = y
smpl @first+1 @last
yadj = @recode(y=na, yadj(-1), y)
Re: fetching data from bloomberg
Thanks Glenn! - I will run it tomorrow on my eviews!
Sorry if this is a basic question (am new to programming in eviews). I have a question on the fetch function. I am pulling time series from bloomberg with the following code:
dbopen(type=bloom) currency
fetch "USSA1" "USSA2" "USSA3" etc....
Later I rename the series one at a time as some of the bloomberg names are not intuitive
series _1= USSA1
series _2 =USSA2
....
My question is how is it that command fetch takes in strings but then I can declare series with the names of those strings. Also How can i apply your code over all the series that the fetch returns without having to assign them all to a different variable (ie _1, _2 etc...)
Sorry if this is a basic question (am new to programming in eviews). I have a question on the fetch function. I am pulling time series from bloomberg with the following code:
dbopen(type=bloom) currency
fetch "USSA1" "USSA2" "USSA3" etc....
Later I rename the series one at a time as some of the bloomberg names are not intuitive
series _1= USSA1
series _2 =USSA2
....
My question is how is it that command fetch takes in strings but then I can declare series with the names of those strings. Also How can i apply your code over all the series that the fetch returns without having to assign them all to a different variable (ie _1, _2 etc...)
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: fetching data from bloomberg
The fetch command doesn't really take in strings per se. It takes in the names of the series to be fetched. Not you do not have to enclose those names in quotes generally. However since some database formats allow spaces in the names of their series, which would kill the fetch command in EViews, we allow you to enclose the name in quotes to handle the spaces.
You will have to create a for loop that loops over all the series you have brought in and apply Glenn's code one at a time in the loop.
You will have to create a for loop that loops over all the series you have brought in and apply Glenn's code one at a time in the loop.
Re: fetching data from bloomberg
Thanks Gareth - that's a lot clearer now! One more thing, how do i loop over all the series without having to write out all the names. Do i put the series into a group then loop through the series say from i to 10 (if there are 10 series) in the group? Also how do I create the group without typing out all the series names again (I'm pulling in over a 100 series so I am trying to avoiding printing out all the names over and over. Thanks again for all the help - I really appreciate it.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: fetching data from bloomberg
You can create the group, that's certainly one way to go. Group creation accepts wildcards, so if the series have a naming pattern, you could use a wildcard.
Or you could use the @wlookup function to return the names of the series in your workfile (again matching a pattern if you wanted).
But, if you're fetching all the series in the same program, you must already have the names of the 100 series in the program some how to begin with.
Or you could use the @wlookup function to return the names of the series in your workfile (again matching a pattern if you wanted).
But, if you're fetching all the series in the same program, you must already have the names of the 100 series in the program some how to begin with.
Re: fetching data from bloomberg
Thanks for all the help
Re: fetching data from bloomberg
HI Gareth/Glenn,
The following code you suggested to remove NAs and to fill in the blanks with the data from the day before, deletes the first row of data when i convert the group to a matrix:
for !i=1 to group01.@count
%name =group01.@seriesname(!i)
smpl @first+1 @last
{%name} = @recode({%name}=na, {%name}(-1), {%name})
next i
When i type matrix m1 = @convert(group01) or when I do stom(group01, m1) the matrix has one less row that the length of the series in the group even though cell 1 in each of the series in the group is populated with a value. How can I fix this please?
Thanks
The following code you suggested to remove NAs and to fill in the blanks with the data from the day before, deletes the first row of data when i convert the group to a matrix:
for !i=1 to group01.@count
%name =group01.@seriesname(!i)
smpl @first+1 @last
{%name} = @recode({%name}=na, {%name}(-1), {%name})
next i
When i type matrix m1 = @convert(group01) or when I do stom(group01, m1) the matrix has one less row that the length of the series in the group even though cell 1 in each of the series in the group is populated with a value. How can I fix this please?
Thanks
Re: fetching data from bloomberg
I understand I just take out the +1 i.e smpl @first @last instead of @first+1 @last. But I am not sure how then to deal with the first value in a series possibly being an NA
N/A fix
HI Gareth/Glenn,
I've asked you this before (sorry for asking again)...N/A fixes with data from bloomberg. Sometimes the code work and sometimes it doesn't, is seems my code doesn't clear out an N/A if it appears at the first entry in a series, could you tell me what is wrong with the following please:
'NA fix
for !i=1 to group01.@count
smpl @first @first
%name =group01.@seriesname(!i)
smpl @first @last
{%name} = @recode({%name}=na, {%name}(-1), {%name})
next i
Thanks!
I've asked you this before (sorry for asking again)...N/A fixes with data from bloomberg. Sometimes the code work and sometimes it doesn't, is seems my code doesn't clear out an N/A if it appears at the first entry in a series, could you tell me what is wrong with the following please:
'NA fix
for !i=1 to group01.@count
smpl @first @first
%name =group01.@seriesname(!i)
smpl @first @last
{%name} = @recode({%name}=na, {%name}(-1), {%name})
next i
Thanks!
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: fetching data from bloomberg
You're replacing NAs with the previous value. If the first value is NA, there is no previous value to replace it with, so it stays an NA.
Re: fetching data from bloomberg
yes of course, sorry
Who is online
Users browsing this forum: No registered users and 2 guests
