BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
camfarrell25
Quartz | Level 8

I'm fairly new to this Macro things and I would like to have a dataset be named according to a parameter that is set using a "macro"-type paremeter -

 

 

DATA _NULL_;
%LET reportingdt = %str(June2016);
RUN;

proc import datafile="C:\Users\cafarrel\Desktop\\REPORTING_DATA.sav"
out=farrsas.reporting_&reportingdt dbms = sav replace;
run;

 

 

 

whenever I run this I get the following error message:

 

NOTE: The SAS System stopped processing this step because of errors.

26 proc import datafile="C:\Users\cafarrel\Desktop\\REPORTING_DATA.sav"

27 out=farrsas.reporting_&reportingdt. dbms = sav replace;

NOTE: Line generated by the macro variable "REPORTINGDT".

27 farrsas.reporting_June2016

________

22

________

202

ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATAFILE, DATATABLE, DBMS, DEBUG, FILE, OUT, REPLACE, TABLE,

_DEBUG_.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

28 run;

 

 

What am i doing wrong? 😞

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

A likely culprit:  quoting functions such as %STR insert unseen quoting characters.  Usually SAS manages to remove them in time, but perhaps that is not happening here.  Try it this way:

 

%let reportingdt = Jun2016;

 

proc import .........; (no changes required)

View solution in original post

3 REPLIES 3
ballardw
Super User

Look closely at of proc import datafile="C:\Users\cafarrel\Desktop\\REPORTING_DATA.sav"

2 slashes in the file name, and since one looks different when I paste it, the second may not be the character it looked like below.

 

Not that it causes the error but this

DATA _NULL_;
%LET reportingdt = %str(June2016);
RUN;

Only needs to be:

 

%LET reportingdt = %str(June2016);

It will help to post log extracts with errors using the entry box brough up by the "run" icon to preserve formating so we can see

where the underlines are generated.

Astounding
PROC Star

A likely culprit:  quoting functions such as %STR insert unseen quoting characters.  Usually SAS manages to remove them in time, but perhaps that is not happening here.  Try it this way:

 

%let reportingdt = Jun2016;

 

proc import .........; (no changes required)

DocSteve
Obsidian | Level 7

try setting the macro variable (first three lines of your program) as follows:

 

%let <macro_variable_name> = <macro_variable_argument> ;

 

The datastep data _null_ is ok but irrelevant (%let can be used in open code).

 

The %str() function seems to be the problem: I ran it without that and the code worked.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1095 views
  • 1 like
  • 4 in conversation