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"
Replacement Variables inside quotes
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13318
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Replacement Variables inside quotes
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:
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
Follow us on Twitter @IHSEViews
Re: Replacement Variables inside quotes
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
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
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13318
- Joined: Tue Sep 16, 2008 5:38 pm
Replacement Variables inside quotes
You should still use WFOPEN or IMPORT.
Follow us on Twitter @IHSEViews
Re: Replacement Variables inside quotes
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
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
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13318
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Replacement Variables inside quotes
Hello, I am trying to loop inside a location path as shown in the codes below.
But it doesn't work. EViews pop up error as :
Can you tell me how to fix it? Thanks!
Best,
BC
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
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13318
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Replacement Variables inside quotes
Remove the braces from around %quarter
Follow us on Twitter @IHSEViews
Re: Replacement Variables inside quotes
oh yes! Got it worked now!
Thank you Gareth!
Thank you Gareth!
Who is online
Users browsing this forum: No registered users and 64 guests