Hi,
I'm using a macro variable which resolves with an array of values seperated by comma and all the values in single quotes. Whenever the macro variable is invoked I could find some unexpected warnings in my log window. The warnings would generally start like 'LINE GENERATED BY MACRO VARIABLE .......' Is there a way or solution to suppress or skip such warnings in the log.
Any help would be highly appreciated.
Thanks
Hi,
What are the actual warning messages you see? It might help others help you, if you can post part of the log.
--Q.
Hi Q, Sorry for the delay in my response. I use Proc SQL in my code where I pull data from database by crosschecking the values of a 'Char' variable with the help of a macro-variable(named as 'mv1' in the below code), which has got values seperated by comma and placed in single quotes. The program runs without errors and generates the expected results but the warnings in the log info should be causing trouble to my job.
Below are the warnings that I come across with...
419 Proc sql EXITCODE;
420 connect to odbc (DSN= xxx);
421 create table t_new as
422 select *
423 from connection to odbc
424 (Select distinct a.var1_num
425 , b.var2_num
426 from db_tab1 a, db_tab2 b
427 WHERE
428 a.var1_num in (&mv1)
NOTE: Line generated by the macro variable "mv1".
428 '00512009390' , '00512009763' , '00512009802' , '00512009972' , '00512010122' , '00512010371' , '00512010876' ,
_____ _____ _____ _____ _____ _____ _____
_____
_____
_____
_____
_____
_____
_____
_____
49 49 49 49 49 49 49
49
49
49
49
49
49
49
49
428 ! '00512010990' , '00512011082' , '00512011511' , '00512011587' , '00512011788' , '00512012349' , '00512012660' ,
428 ! '00512013046' , '00512013134'
NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS release. Inserting white space
6 The SAS System
between a quoted string and the succeeding identifier is recommended.
49: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL may allow recovery of the LINE and COLUMN where the error has occurred.
NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS release. Inserting white space
between a quoted string and the succeeding identifier is recommended.
NOTE: Line generated by the macro variable "mv1".
428 , '00512013174' , '00512013580' , '00512013965' , '00512014022' , '00512014491' , '00512014756' , '00512016086' ,
_____ _____ _____ _____ _____ _____ _____
_____
_____
_____
_____
_____
49 49 49 49 49 49 49
49
49
49
49
49
428 ! '00512959341' , '00512971158' , '00512982709' , '00512994544' , '78012460070' , '85012418823'
NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS release. Inserting white space
between a quoted string and the succeeding identifier is recommended.
429 and a.tb_var1= b.tb_var2
430 order by a.tb_var1
431 );
NOTE: Table WORK.t_new created, with 98 rows and 2 columns.
Although my job completes successfully I end up with an error prompt. Not sure, but I believe that the errors thrown could be from the above warnings. Any ideas would be highly appreciated
Thanks in advance
The best solution would be to change how &MV1 gets constructed. Make sure there is a space before each comma. That should be easy enough, if you actually have control over its creation. For example, if it is created by SQL, change
separated by ','
to
separated by ' ,'
The error you are seeing is a result of SAS assigning meaning to some characters that follow a closing quote, such as:
'01JAN1960'd
'Silly Variable Name'n
SAS is warning you about placing a character after a closing quote, because future releases of the software may expand the list of characters that have special meaning if they follow a closing quote.
Good luck.
Thanks Astounding, Your observation is true and really great. While creating this macro I tried to prefix and suffix with single quotes to the entire string as below and I think, my logic is not working and that should have been the result.
%LET mv1 = %STR(%' &Values. %');
Here &Values is created from SQL as you mentioned above.
Could you please guide me if I'm wrong with the above function.
Thanks a lot!!
This looks like %LET should be removed, and PROC SQL should put in all the quotes. For example, within SQL:
select "'" || strip(value) || "'" into : mv1 separated by ' , '
(Those are single quotes within double quotes.)
The SELECT statement can add quotes around each value, as well as insert commas.
It is entirely possible that your %LET statement adds to the problem by adding a quote at the beginning. Now macro language generates two quotes, followed by a number. SAS may be complaining that the number is following a closing quote. Commas would probably never be added as a significant character following a closing quote, but a number might. Unlikely, but might. At any rate, clean up the SQL statement and let it do all the work.
Thanks again.. this really helped me and resolved my issue. Wonderful day for me!!
I am not sure if this would help, but no hurt to try:
options nonotes nosource nomacrogen;
BTW, notes and warning being there for a reason, the last thing I want to do is to suppress them.
Haikuo
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!
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.
Ready to level-up your skills? Choose your own adventure.