Saving dataset within a macro where the name is flexible

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

Saving dataset within a macro where the name is flexible

Hi Commuity,

 

I have a very simple problem you can probably easily resolve. 

 

I have the following macro:

%macro Interval(secs);

data forexExport;
set want7;
minutestime = floor(seconds_time/(&secs.));
run;

data forexExport;
  set forexExport;
  by minutestime;
  if last.minutestime;   
run;

data forexExport;
set forexExport;
log_price = log(RateBid + (RateAsk - RateBid)/2);
run;

proc export data=work.forexExport 
   outfile='F:\data\EUR_USD_201517_&secs.sec.csv'  <- ERRONEOUS LINE
   dbms=csv
   replace;
run;


%mend;

%Interval(900);

the issues lies in the outfile statement (marked with an arrow for you). What it is supposed to do is take the input variable, which in this case is set to 900 and use is within the filename. After exporting, it should basically read "EUR_USD_201517_900sec". What it does read instead is "EUR_USD_201517_&secs.sec" so what I used to reference within the macro. I am new to sas so I have trouble finding the issue with my referencing.

 

Thank you very much in advance!

 

Best wishes


Accepted Solutions
Solution
‎04-27-2018 05:49 AM
Super User
Super User
Posts: 9,599

Re: Saving dataset within a macro where the name is flexible

Posted in reply to NewSASuser2018

You need to put double quotes around macro variables to get them to resolve:

   outfile="F:\data\EUR_USD_201517_&secs.sec.csv" 

 

View solution in original post


All Replies
Solution
‎04-27-2018 05:49 AM
Super User
Super User
Posts: 9,599

Re: Saving dataset within a macro where the name is flexible

Posted in reply to NewSASuser2018

You need to put double quotes around macro variables to get them to resolve:

   outfile="F:\data\EUR_USD_201517_&secs.sec.csv" 

 

Contributor
Posts: 22

Re: Saving dataset within a macro where the name is flexible

Thank you very much!
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 111 views
  • 1 like
  • 2 in conversation