@wreplace(%eq,"*[*", "*(*")

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

tvonbrasch
Posts: 569
Joined: Fri Apr 15, 2011 5:35 am

@wreplace(%eq,"*[*", "*(*")

Postby tvonbrasch » Wed Aug 26, 2015 12:12 pm

Hi

I want to replace [ with ( in a string. But this does not work with the code:

%eq=@wreplace(%eq,"*[*", "*(*")
%eq=@wreplace(%eq,"*]*", "*)*")

where the string %eq= "0*U65+d(LOG(U65),1)=UR65+Urcon65+ucon65(1)+ucon65[2]*d(LOG(U65(-2) ) ,1)+ucon65[3]*d(LOG(U65(-10)),1)+ucon65[4]*d(LOG(x65),1)+ucon65[5]*(LOG(U65(-1)/x65(-1))-0.2*LOG(w65(-1)/pF65(-1))-0.75*LOG(pM65(-1)/pF65(-1))+0.0055757*TID)+ucon65[6]*DKV1+ucon65[7]*DUM901"

what am i doing wrong?
THomas

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

Re: @wreplace(%eq,"*[*", "*(*")

Postby EViews Gareth » Wed Aug 26, 2015 1:06 pm

@wreplace replaces words. You want @replace

tvonbrasch
Posts: 569
Joined: Fri Apr 15, 2011 5:35 am

Re: @wreplace(%eq,"*[*", "*(*")

Postby tvonbrasch » Thu Aug 27, 2015 12:34 am

Hi

Thanks for your reply.
What do you mean by replacing words, in the help menu it states
Example:
@wreplace("ABC AB", "*B*", "*X*")
replaces all instances of “B” with “X”, returning the string “AXC AX”.

which is not a replacement of words...?

The command

show @replace("0.0055757*TID+ucon65[6]","*TID*", "*(*") also yields "0.0055757*TID+ucon65[6]"
(but the command %eq=@wreplace("0.0055757*TID+ucon65[6]","*[1]*", "*(1)*") works for some reason)

Note that the commands
show @replace("0.0055757*TID+ucon65[6]","*TID*", "*TEST*") yields "0.0055757*TID+ucon65[6]", while

show @wreplace("0.0055757*TID+ucon65[6]","*TID*", "*TEST*") yields "0.0055757*TEST+ucon65[6]"

I am a bit confused about these commands....?

Neither of them manages to replace [ with ( ?

Can you please take another look at it?
Thomas
Last edited by tvonbrasch on Thu Aug 27, 2015 1:27 am, edited 1 time in total.

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: @wreplace(%eq,"*[*", "*(*")

Postby trubador » Thu Aug 27, 2015 1:00 am

The following would yield the same output:

Code: Select all

@wreplace("0.0055757*TID+ucon65[6]","*[*", "*(*") @replace("0.0055757*TID+ucon65[6]","[", "(")
It does not work in your case because @wreplace considers %eq as a whole word as there are no spaces in it. And therefore it will only change the first instance (...ucon65[2]...). Do not use * or ? in @replace, since it does not look for patterns as @wreplace do.

tvonbrasch
Posts: 569
Joined: Fri Apr 15, 2011 5:35 am

Re: @wreplace(%eq,"*[*", "*(*")

Postby tvonbrasch » Thu Aug 27, 2015 9:41 am

ah, thanks, that explains it :-)


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 1 guest