BookmarkSubscribeRSS Feed
zoomzoom
Obsidian | Level 7

I am trying to write a program involving a macro, and it fails at a very initial stage.

 

Code:

options symbolgen mprint mlogic;

%let lib=aa_temp1;

%let dsname=Party_Details;

 

%macro test;

 

data test11;

set &lib..&dsname.; 

run;

 

%mend;

%test();

 

Error when executed:

 

SYMBOLGEN: Macro variable lib resolves to aa_temp1

SYMBOLGEN; Macro variable dsname resolves to Party_Details

 

data test11;  set &lib..&dsname.;  run;

                    ____

                     180

ERROR 180-322: Statement is not valid or used out of proper order.

MPRIINT(TEST): Set aa_temp1.Party_Details;

 

I have tried the dsname in Set as &dsname as well as &dsname. , and there is the same error. Tried searching for the error, and still not sure why this simple line generates error. What is that I am missing?

 

 

 

 

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

Your code as shown works fine.

%let lib=sashelp;
%let dsname=class;
%macro test;
  data test11;
    set &lib..&dsname.; 
  run;
%mend;
%test;
MLOGIC(TEST):  Beginning execution.
MPRINT(TEST):   data test11;
SYMBOLGEN:  Macro variable LIB resolves to sashelp
SYMBOLGEN:  Macro variable DSNAME resolves to class
MPRINT(TEST):   set sashelp.class;
MPRINT(TEST):   run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.TEST11 has 19 observations and 5 variables.
NOTE: DATA statement used:
      real time           0.01 seconds
      cpu time            0.00 seconds


MLOGIC(TEST):  Ending execution.

I suspect you are doing something different and your macro values are quoted. Try using the %unquote() function.

Quentin
Super User

Yes, please double-check that the code you posted is the same as the code you submitted.

 

Note that your macro call %test() ;  has parentheses, even though the macro does not have any parameters.  This will create the error message you get, though not near the SET statement.  So @ChrisNZ's suggestion about possible macro quoting in your real code is a good one. 

 

WHen I run your code as is, I get below log:

26   %test();
MLOGIC(TEST):  Beginning execution.
MPRINT(TEST):   data test11;
SYMBOLGEN:  Macro variable LIB resolves to aa_temp1
SYMBOLGEN:  Macro variable DSNAME resolves to Party_Details
MPRINT(TEST):   set aa_temp1.Party_Details;
MPRINT(TEST):   run;

NOTE: There were 1 observations read from the data set AA_TEMP1.PARTY_DETAILS.
NOTE: The data set WORK.TEST11 has 1 observations and 1 variables.

MLOGIC(TEST):  Ending execution.
180: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN
      where the error has occurred.
ERROR 180-322: Statement is not valid or it is used out of proper order.
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
zoomzoom
Obsidian | Level 7
Quentin and Chris,

Thank you for your input. I have closed the session, reopened and executed the same code - and it works now. Atleast I have learnt something new from you two.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 866 views
  • 2 likes
  • 3 in conversation