Exporting dates to xlsx?

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

paues
Posts: 201
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Exporting dates to xlsx?

Postby paues » Fri Apr 05, 2013 6:13 am

Is it possible in EViews 8 to export dates to xlsx files alongside data? And is it possible to export dates only? And is it possible to stop the series names from being exported with the data? Now, I can get the command to export data only with the command below.

Code: Select all

wfsave(t=excelxml, mode=update, noid) MyFile.xlsx nonames range="Sheet1!B5" byrow @keep segdp dkgdp nogdp figdp isgdp @smpl 2000 2012
However, I would like to pick and choose. That is, I would like to be able to whether or not data, dates and series names should be included in the export.

EViews Chris
EViews Developer
Posts: 161
Joined: Wed Sep 17, 2008 10:39 am

Re: Exporting dates to xlsx?

Postby EViews Chris » Fri Apr 05, 2013 10:24 am

Could you be a bit more specific?

The 'noid' and 'nonames' options in your command will suppress the extra header row/col containing the ids (dates) and series names at the edges of the table you are writing. You can use any combination of the options to switch off one, both or neither of these.

We don't currently allow you to switch the headers on and off on a series by series basis. You could do something like this by splitting the operation into multiple commands, where each command wrote out part of the data (using the @keep statement). You could then choose to have or not have headers on each section that you write.

To write only a column of observation dates, you could use '@keep @date' or '@keep @enddate' to specify a series containing the start or end dates of each observation in the workfile (using the 'noids' option to suppress an additional column of dates).

Some of this is a bit fussy, which largely comes from the fact that many of the other formats we write to are much more heavily structured and require column names attached to every column we write (relational databases, formats of all other statistics packages, etc.). We should probably loosen things up a bit for cases like excel and text files where an empty column name is feasible.

There's a totally different issue that I wondered whether you might be refering to, which is that when we update an existing Excel file, the dates will show up as numbers unless the cells in the Excel file have already been set to have a date format. What's going on here is that although we are passing dates across to the Excel application (which performs the actual update on the file) it simply treats it as a number - I assume because it doesn't want to change the formatting of the cell just because the value being assigned to it is a date. We could possibly add an option here that would say 'always override existing formats when writing dates' which would then let us force our own date format onto these cells so that they would always display as dates within Excel, but at the moment we don't adjust any formatting information during an update operation.

paues
Posts: 201
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Re: Exporting dates to xlsx?

Postby paues » Fri Apr 05, 2013 1:28 pm

Thank you for your extensive answer! And please excuse my vague question. (I was planning to ask a different question originally, but changed my mind mid-writing, leaving traces of the initial questions in the text.)

Your '@keep @date' pointer solved my problem (together with the arguments 'noid' and 'nonames' which I already knew).

However, I have been able to pinpoint the problem I was originally planning to write about: I would expect these two chunks to generate two identical exports to the sheets Sheet1 and Sheet2. However, Sheet1 gets dates and data while Sheet2 gets only data. The problem seems to stem from the pagecontract command, but I cannot figure out why and how to solve it.

Code: Select all

close @all wfcreate q 1980 2013 smpl 1980 2010 series segdp=1 smpl @all wfsave(t=excelxml) k:\Stab\testQ.xlsx range="Sheet1!B5" byrow @keep segdp group alla * pagecontract if @robs(alla)>0 smpl @all wfsave(t=excelxml,mode=update) k:\Stab\testQ.xlsx range="Sheet2!B5" byrow @keep segdp

EViews Chris
EViews Developer
Posts: 161
Joined: Wed Sep 17, 2008 10:39 am

Re: Exporting dates to xlsx?

Postby EViews Chris » Fri Apr 05, 2013 3:58 pm

OK. I see what is going on. We'll fix this in the next patch that goes out. (Not the patch that that just went out today though).

There's some code in EViews that tries to prevent multiple copies of the series containing observation dates building up in your page if you import and export the same file a few times in a row. (Caused by writing both a series containing the observation dates *and* the column of observation dates in a separate header).

It wasn't correctly handling the case where you're selecting a limited set of columns to write using an @keep statement.

For what it's worth, deleting the series 'obsid' that is popping up in the workfile after the pagecontract command will make the problem 'go away' in your example.

paues
Posts: 201
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Re: Exporting dates to xlsx?

Postby paues » Tue Apr 09, 2013 12:28 am

Thank you for the tip about deleting the series obsid! Two related issues: is it possible to export only

(1) ...series names?
(2) ...series labels?

johansamuelsson
Posts: 165
Joined: Thu Mar 03, 2011 10:07 pm
Contact:

Re: Exporting dates to xlsx?

Postby johansamuelsson » Mon Apr 15, 2013 6:07 am

How about this question, i.e. exporting names or/and labels?

Regards Johan

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

Re: Exporting dates to xlsx?

Postby EViews Gareth » Mon Apr 15, 2013 8:03 am

Not currently.

shm83
Posts: 35
Joined: Tue Sep 10, 2013 5:00 am

Re: Exporting dates to xlsx?

Postby shm83 » Thu Dec 19, 2013 5:05 am

and is it possible to export a series (alphaseries) to a text file without quotes and without the alphaseries names??


Being SeriesAlpha1 my alpha series

Code: Select all

save(type=text) "D:\Exit1.txt" @keep SeriesAlpha1 write(t=txt, nonames) d:\Exit2.txt SeriesAlpha1
I get
"Pre('1') = 1"
"Pre('2') = 7"
"Pre('3') = 6"
"Pre('4') = 5"
"Pre('5') = 4"
or
SeriesAlpha1
Pre('1') = 1
Pre('2') = 7
Pre('3') = 6
Pre('4') = 5
Pre('5') = 4
respectively. What I would like is a file containing the content of the series without quotes (as the second one) but withot the name of the alphaseries.

Thank you in advance

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

Re: Exporting dates to xlsx?

Postby EViews Gareth » Thu Dec 19, 2013 8:46 am

Code: Select all

wfsave(type=text) myfile.txt nonames @keep seriesalpha1


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests