BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

Looking for some help on this error. Code which I've is similar to below

 

%macro temp_data( 
    out_sales_tbl=     
) / minoperator;

data WORK.&out_sales_tbl._hdp ;
....
run;
%mend;

and we are calling the above macro as below. Value for this macro variable (out_sales_tbl) will be resolved by other macro.

 

 %temp_data (
    out_sales_tbl=%quote(&out_sales_tbl)
     );

Error which I got is,

SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.
SYMBOLGEN:  Macro variable OUT_SALES_TBL resolves to out_sales_table
SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.
NOTE: Line generated by the macro variable "OUT_SALES_TBL".
211  WORK.out_sales_table_hdp
                         ----
                         22
                           ----
                           202
10 REPLIES 10
LinusH
Tourmaline | Level 20

Do you  have logic in trhe macro that affects the value of said macro variable?

Otherwise, why do you need to resolve it within the macro?

I guess I need to see the full code to be able to give you an appropriate advice.

Data never sleeps
yabwon
Onyx | Level 15

Try this:

%macro temp_data( 
    out_sales_tbl=     
) / minoperator;

data WORK.%unquote(&out_sales_tbl._hdp) ;
....
run;
%mend;

Good macroquoting reading:

"Secrets of Macro Quoting Functions – How and Why" by Susan O’Connor

 

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Babloo
Rhodochrosite | Level 12

@yabwon still the same error

yabwon
Onyx | Level 15

My bad, try this:

%unquote(WORK.&out_sales_tbl._hdp)

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Babloo
Rhodochrosite | Level 12

@yabwon  still the same error

yabwon
Onyx | Level 15

Show the log.

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



PaigeMiller
Diamond | Level 26

@Babloo wrote:

@yabwon still the same error


Please give us information that we can work from. Show us the entire LOG for this code you are working with (not just the ERROR messages). Also please show us the entire CODE, including the part where the macro variable is assigned a value. Also, please answer @Kurt_Bremser's question.

 

 

--
Paige Miller
Quentin
Super User

Can you show the log from running @yabwon's original suggestion, I think it should work.

 

But more importantly, please make a small example of this problem, and post the code and the log you get.

 

From what I can see in the log you've shared, you've got code like:

 

%let out_sales_tbl=out_sales_table ;

%macro temp_data(out_sales_tbl=);
  %put _local_ ;
  data WORK.&out_sales_tbl._hdp ;
  run;
%mend;

%temp_data(out_sales_tbl=%quote(&out_sales_tbl))

As others have pointed to the macro quoting is not needed. Also note the &out_sales_tbl is resolved during the call to temp_data.  If you want to delay that, you would need to use %nrstr().  The quoting characters introduced by %quote() cause problems for the compiler, but @yabwon's %unquote suggestion resolves them for my test:

 

%let out_sales_tbl=out_sales_table ;

%macro temp_data(out_sales_tbl=);
  %put _local_ ;
  data WORK.%unquote(&out_sales_tbl._hdp) ;
  run;
%mend;

%temp_data(out_sales_tbl=%quote(&out_sales_tbl))
BASUG is hosting free webinars Next up: Mike Raithel presenting on validating data files on Wednesday July 17. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Tom
Super User Tom
Super User

The simple solution is to fix the CALL to the macro.

A valid dataset name cannot contain any character that needs macro quoting so don't quote it.

Plus you are just confusing yourself by calling the macro with the value of a macro variable that has the same name as the macro variable used as the parameter name.

%let some_other_mvar = table_name;
%temp_data(out_sales_tbl=&some_other_mvar);

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 10 replies
  • 1112 views
  • 5 likes
  • 7 in conversation