DATA Step, Macro, Functions and more

Macro keyword parameters not resolving (Please Help)

Reply
Occasional Contributor
Posts: 13

Macro keyword parameters not resolving (Please Help)

Hello Forum,

I'm trying to create a macro that will import 12 months worth of data from 12 separate files.  I receive error messages that symbolic reference MTH01 and MON01 cannot resolve.  I also receive an error 22-322: syntax error, expecting one of the following: ;, (, DATAFILE, DATATABLE, DBMS, DEBUG, FILE, OUT....etc.  I thought that a macro previously defined in a program could later be invoked within a macro?

 

Can someone please tell me what I'm doing wrong or what I can do to correct this?  Thank you very much in advance.

~ Eric

 

rsubmit;

%let MTH01=%sysfunc(dequote("'%sysfunc(intnx(MONTH,%sysfunc(today()),-1),monyy7.)'"));

%let MON01=%sysfunc(dequote("'%sysfunc(intnx(MONTH,%sysfunc(today()),-1),mmyyn6.)'"));

endrsubmit;

 

%macro import(MONYY=,MMYY=);

PROC IMPORT OUT=tpt_lvt_his_&MMYY.

DATAFILE= "\\xxxxxxx\xxxxxxx\xxxxx\xxxx\xxxxx\xxxx\&MONYY.\TPT_ora_apples_&MMYY. (from zzz Sharepoint).xls"

DBMS=EXCEL REPLACE;

GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES;

RUN;

 

%mend;

%import (MONYY=&MTH01.,MMYY=&MON01.);

 

Super User
Posts: 19,780

Re: Macro keyword parameters not resolving (Please Help)

Is your endrsubmit early?

 

You need to compile the macro and macro variables in the same location - both locally or both on the server.

 

Your macro variable can't have quotes though, otherwise the code generated is:

 

 

MMYY resolves to -> '102016'

PROC IMPORT OUT=tpt_lvt_his_&MMYY. becomes

PROC IMPORT OUT=tpt_lvt_his_'102016'

 

This isn't valid SAS sytnax.

The code becomes simpler though:

 

%let MON01=%sysfunc(intnx(MONTH,%sysfunc(today()),-1),mmyyn6.);

Ask a Question
Discussion stats
  • 1 reply
  • 130 views
  • 0 likes
  • 2 in conversation