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))
The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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