importattr command

For questions regarding programming in the EViews programming language.

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

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

importattr command

Postby BT454 » Tue Oct 02, 2018 5:44 am

Hi all,
I'm attempting to assign various attribute fields to several series in a data job.
I can successfully import the attribute fields into my workfile as series using this command:

pageload(page=attributes) c:\warem32\cdb_attr.xlsx range="annual!b1:mw20" byrow colhead=0 names=("name", Geography, concept, Product, Unit, "Bank Name(s)", Mnemonic, "Base Period", "Data Edge", "End Date", "Last Update", "Long Label", Real/Nominal, Scale, "Seasonal Adjustmnet", "Series Type", "Short Label", Source, "Start Date", Frequency)

However, when I try to store the attributes in the desired data objects within the same workfile (while overwriting existing attributes) nothing happens.
I am using these commands:

pageselect annual '(the page in which the data objects exist)

importattr(o) attributes @keep all '(I've tried to import just one attribute as well, and still, nothing happens).

Any thoughts on why this code wouldn't work, or if I'm missing something? I've attached the workfile for reference.
dbdata.wf1
(2.47 MiB) Downloaded 235 times

Thanks,
Bob

EViews Steve
EViews Developer
Posts: 788
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: importattr command

Postby EViews Steve » Tue Oct 02, 2018 7:19 am

I downloaded your workfile, switched to the annual page, then ran the following command in the command window:

Code: Select all

importattr(o) attributes


and when I checked a series on the annual page, it had all the attributes:

screenshot1.png
screenshot1.png (64.12 KiB) Viewed 5973 times


Is this what you're looking for?

By the way, IMPORT & WFOPEN commands can both read various different columns of your data as attributes instead of series so you can import everything in a single step. This was introduced in EViews 10. Look at the "colheadnames" argument in the WFOPEN help page, or look at this short video about the process on our EViews 10 Whats New page.

Steve

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

Re: importattr command

Postby BT454 » Tue Oct 02, 2018 7:57 am

Thanks, Steve.
I'm running the same command and it's not working...I've using eviews 10 (I've tried it in both 32 and 64 bit versions). Is there something I'm missing?
Thanks,
Bob

EViews Steve
EViews Developer
Posts: 788
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: importattr command

Postby EViews Steve » Tue Oct 02, 2018 8:00 am

If you haven't updated to the latest patch, please do so and try again.

Otherwise, I'm not sure why you're seeing different behavior. Did you manually run the commands via the command window or did you run the program again?

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

Re: importattr command

Postby BT454 » Tue Oct 02, 2018 8:00 am

That worked! Could you instruct me on how to remove the already existing "description" attribute from each series?
Thanks again!
Bob

EViews Steve
EViews Developer
Posts: 788
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: importattr command

Postby EViews Steve » Tue Oct 02, 2018 8:21 am

You responded so quickly, I'm curious -- what did you do differently that made it work?

I thought the import's overwrite mode would overwrite any previous description. Is that not working as expected? Oh, you're not writing to the description value...

Well if you want to clear or set all description values for all objects on your page, you can do something like this:

Code: Select all

%names = @wlookup("*")
for %name {%names}
   {%name}.label(d)
next

or if you want to set it to a specific value:

Code: Select all

%names = @wlookup("*")
for %name {%names}
   {%name}.label(d) "new value"
next

Here's the help page for label property.

Steve

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

Re: importattr command

Postby BT454 » Tue Oct 02, 2018 10:50 am

Thank you very much, Steve.
I wasn't viewing the series correctly to see the label. Once I changed that, it worked.
Do you know if there is a way to select just one attribute out of many to be cleared, for each series (using a similar loop as you described above)?
Thanks,
Bob

BT454
Posts: 135
Joined: Wed Aug 02, 2017 6:07 am

Re: importattr command

Postby BT454 » Tue Oct 02, 2018 10:59 am

Sorry for the false alarm. I figured out a workaround by clearing all labels before importing the new ones. And there was some confusion on my end as I didn't realize "description" was an existing field for labels/attributes. I had imported an attribute field titled attribute, without knowing it was part of Eviews existing syntax.
Thanks again!
Bob


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 19 guests