BookmarkSubscribeRSS Feed
Babloo
Barite | Level 11

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
Meteorite | Level 14

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
Barite | Level 11

@yabwon still the same error

yabwon
Meteorite | Level 14

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
Barite | Level 11

@yabwon  still the same error

yabwon
Meteorite | Level 14

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
PROC Star

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))
Check out the Boston Area SAS Users Group (BASUG) video archives: https://www.basug.org/videos.
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);

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 10 replies
  • 308 views
  • 5 likes
  • 7 in conversation