Page 1 of 1
Replacement Variables inside quotes
Posted: Thu May 19, 2011 10:44 am
by sfawver
I've seen posts saying you can't include replacement variables inside quotes. Has anyone figured out a work around for this?
Is this example in the help the work around?
%b = "mom!"
%a = "hi %b"
table(1, 2) = %a
%a = "hi " + %b
This is what I've tried but can't get it to work.
%dir="Copy of 2011Q1"
allmsa.read(t=xls, a1, s=All436areas) "\\Pmi-shares\Risk Management\Economics & Strategy\HPFM\Scott_eviews\"+{%dir}+"\All436areas.xls"
allmsa.read(t=xls, a1, s=All436areas) "\\Pmi-shares\Risk Management\Economics & Strategy\HPFM\Scott_eviews\{%dir}\All436areas.xls"
Re: Replacement Variables inside quotes
Posted: Thu May 19, 2011 11:21 am
by EViews Gareth
First of all, if you're using EViews 7, you should not be using the READ command, rather you should use IMPORT or WFOPEN.
Secondly, in answer to your question, you'll have to create intermediary variables that contain the full path:
Code: Select all
%dir="Copy of 2011Q1"
%path1 = "\\Pmi-shares\Risk Management\Economics & Strategy\HPFM\Scott_eviews\"+{%dir}+"\All436areas.xls"
allmsa.read(t=xls, a1, s=All436areas) %path1
%path2 = "\\Pmi-shares\Risk Management\Economics & Strategy\HPFM\Scott_eviews\{%dir}\All436areas.xls"
allmsa.read(t=xls, a1, s=All436areas) %path2
Re: Replacement Variables inside quotes
Posted: Thu May 19, 2011 12:35 pm
by sfawver
Got it. This works.
The file I'm reading in isn't the workfile. It's a table of MSA codes needed to loop through the regressions.
%dir="Copy of 2011Q1"
%file1="\All436areas.xls"
%file2="\UR_NSA_Forecasts_eq1_2011Q1.xls"
%path="\\Pmi-shares\Risk Management\Economics & Strategy\HPFM\Scott_eviews\"
%fullpath=%path + %dir
%fullfile1=%path + %dir + %file1
%fullfile2=%path + %dir + %file2
allmsa.read(t=xls, a1, s=All436areas) %fullfile1
ur_nsaf_vector.write(t=xls) %fullfile2
Replacement Variables inside quotes
Posted: Thu May 19, 2011 12:37 pm
by EViews Gareth
You should still use WFOPEN or IMPORT.
Re: Replacement Variables inside quotes
Posted: Thu May 19, 2011 1:57 pm
by sfawver
I do see wfopen is faster but it creates a new workfile. Is there a way to use wfopen to create a series in an existing workfile?
this is what i'm using
allmsa.read(t=xls, a1, s=All436areas) %fullfile1
this creates a new workfile and i can't figure out how to name the series
wfopen(wf=allmsa page=All436areas name=allmsa) %fullfile1
Re: Replacement Variables inside quotes
Posted: Thu May 19, 2011 2:01 pm
by EViews Gareth
IMPORT
Re: Replacement Variables inside quotes
Posted: Mon Jun 19, 2017 10:03 am
by bcchen
Hello, I am trying to loop inside a location path as shown in the codes below.
Code: Select all
for %quarter 07q4 08q1 08q2
%file1="c:\users\bc03760\desktop\i-common field building\datarows\quarter workfiles\common field round\common filed round 2 apploan-acct attribute\commonfiled_"+{%quarter}+"apploan_2.wf1"
wfopen %file1
next
But it doesn't work. EViews pop up error as :
%FILE1 is not defined or is an illegal command in
"%FILE1="C:\USERS\BC03760\DESKTOP\I-COMMON FIELD
BUILDING\DATAROWS\QUARTER WORKFILES\COMMON
FIELD ROUND\COMMON FILED ROUND 2 APPLOAN-ACCT
ATTRIBUTE\COMMONFILED_"+07Q4+"APPLOAN_2.WF1"".
Can you tell me how to fix it? Thanks!
Best,
BC
Re: Replacement Variables inside quotes
Posted: Mon Jun 19, 2017 10:18 am
by EViews Gareth
Remove the braces from around %quarter
Re: Replacement Variables inside quotes
Posted: Mon Jun 19, 2017 10:54 am
by bcchen
oh yes! Got it worked now!
Thank you Gareth!