BookmarkSubscribeRSS Feed
pawan
Obsidian | Level 7

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

8 REPLIES 8
Quentin
Super User

Hi,

What are the actual warning messages you see?  It might help others help you, if you can post part of the log.

--Q.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
pawan
Obsidian | Level 7

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

Astounding
PROC Star

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.

pawan
Obsidian | Level 7

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!!

Astounding
PROC Star

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.

pawan
Obsidian | Level 7

Thanks again.. this really helped me and resolved my issue. Wonderful day for me!!

Haikuo
Onyx | Level 15

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 8 replies
  • 1219 views
  • 2 likes
  • 5 in conversation