BookmarkSubscribeRSS Feed
Nasser_DRMCP
Lapis Lazuli | Level 10
%macro mc_library_table_list2(p_lib_name , p_table_name) ;
option nomprint nodate nonumber nonotes nosymbolgen nosource ;
title ="" ;

proc printto log="/home/ldap/mellouna/log_script.txt" new;  run;

%do i=1 %to 10 ;
proc sql nofeedback ;
  describe table &p_lib_name..&p_table_name. ;
quit;

%end;

%mend ;


%mc_library_table_list2(p_lib_name=SASHELP , p_table_name=CLASS) ;

hello,
by launching this code I can see the text "The SAS System" printed into the log file. how could I get rid of this ?
thanks a lot in advance
Nass

 

15 REPLIES 15
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You can't, it will always tell you some information about the environment which it is using to compile.  Why would you need to, just redirect what log information you need to another file.

Nasser_DRMCP
Lapis Lazuli | Level 10

Thanks RW9

 

I have got many tables in the production environment and I need to create them (only stucture, no datas) in another test environment.

So after creating this script in production I can launch it in test.

Tom
Super User Tom
Super User

Perhaps if you removed the equal sign from the TITLE statement?

title ' ' ;

Also you should make your macro reset the options back to the way it found them.

%macro mc_library_table_list2(p_lib_name , p_table_name) ;
%local save;
%let save=
 %sysfunc(getoption(mprint))
 %sysfunc(getoption(date))
 %sysfunc(getoption(number))
 %sysfunc(getoption(notes))
 %sysfunc(getoption(symbolgen))
 %sysfunc(getoption(source))
;
options nomprint nodate nonumber nonotes nosymbolgen nosource ;
 
....

options &save;
%mend ;
Nasser_DRMCP
Lapis Lazuli | Level 10

thanks Tom

but "The SAS System" still printed in the log file

 

Tom
Super User Tom
Super User
It didn't when I ran your test. Did you make sure to turn off the PRINTTO? You did not include that in your example code. Or try setting the TITLE to some invisible character like 'A0'x.
Nasser_DRMCP
Lapis Lazuli | Level 10

with title 'A0'x ; the message still appears.

I check the log tab in sas EG and I can see that

"Project Log turned off"

should I specify to turn off the PRINTTO in the code macro ?

 

Tom
Super User Tom
Super User

I ran your example and did not get any title statements in the file generated by the PROC PRINTTO LOG=.

Where are you seeing this line?

%macro mc_library_table_list2(p_lib_name , p_table_name) ;
%local save;
%let save=
 %sysfunc(getoption(mprint))
 %sysfunc(getoption(date))
 %sysfunc(getoption(number))
 %sysfunc(getoption(notes))
 %sysfunc(getoption(symbolgen))
 %sysfunc(getoption(source))
;
option nomprint nodate nonumber nonotes nosymbolgen nosource ;

proc printto log=test  new;  run;

%do i=1 %to 10 ;
proc sql nofeedback ;
  describe table &p_lib_name..&p_table_name. ;
quit;

%end;
proc printto log=log; run;
options &save;
%mend ;

title 'Here is my title';
filename test temp;
%mc_library_table_list2(p_lib_name=SASHELP , p_table_name=CLASS) ;
data _null_;
  infile test;
  input;
  put _infile_;
run;
Nasser_DRMCP
Lapis Lazuli | Level 10

please find attached my log file . line 35

Tom
Super User Tom
Super User

Your example was do the same table description 10 times. The log you posted is for different tables.

How did you get it to run for different tables?  Perhaps in there you triggered some other step that generated the title statement?

 

Nasser_DRMCP
Lapis Lazuli | Level 10

very sorry. please find enclosed the right log file. (the same table description 10 times.)line 53.

10 times (loop 10)  is just just an example to describ the probem. with loop 5 the text is not displayed.

Tom
Super User Tom
Super User

I cannot re-create the issue.

 

Run the code I posted that writes the lines to a temp file and then echos the resulting file back to the SAS log using a data _null_ step. 

 

Do you see the title lines in that?  If so then raise an issue with SAS support and perhaps they can figure out if there is some other option that controls the generation of those title lines in the re-directed log.

 

Nasser_DRMCP
Lapis Lazuli | Level 10

Tom, I copy /paste and run your code but I can not find the "test" file

 

Tom
Super User Tom
Super User

The TEST fileref in my original program was using the TEMP engine to make a temporary file. So it will disappear when SAS is done.  You could change the FILENAME statement to have it write a real file instead.

 

I was able to recreate the problem by running the program in batch (background) mode instead of from Display Manager.

I tried use PROC OPTSAVE to save the option settings and see if there were any options that were set differently when running in batch versus interactive that could change that.

 

At this point your best bet is make it a two step process.

One that redirects the log.

And then a post processing step that reads the redirected log and writes it back out without the extra title lines.

 

Or even better forget about this and just generate your own table descriptions from the metadata you can get from PROC CONTENTS or DICTIONARY.COLUMNS.  This has the added benefit that you can decide what information is important and what format to use. For example you could write the commas that delimit the column names at the beginning of the lines instead of the end so that the code is easier to for humans to scan. 

create table CARS( label='2004 Car Data' )
  (Make char(13)
  ,Model char(40)
  ,Type char(8)
  ,Origin char(6)
  ,DriveTrain char(5)
  ,MSRP num format=DOLLAR8.
  ,Invoice num format=DOLLAR8.
  ,EngineSize num label='Engine Size (L)'
  ,Cylinders num
  ,Horsepower num
  ,MPG_City num label='MPG (City)'
  ,MPG_Highway num label='MPG (Highway)'
  ,Weight num label='Weight (LBS)'
  ,Wheelbase num label='Wheelbase (IN)'
  ,Length num label='Length (IN)'
  )
;

Or you could generate SAS code instead of SQL code.

data cars (label='2004 Car Data');
  length Make $13 Model $40 Type $8 Origin $6 DriveTrain $5
    MSRP 8 Invoice 8 EngineSize 8 Cylinders 8 Horsepower 8
    MPG_City 8 MPG_Highway 8 Weight 8 Wheelbase 8 Length 8
  ;
  format MSRP dollar8. Invoice dollar8. ;
  label EngineSize='Engine Size (L)' MPG_City='MPG (City)'
    MPG_Highway='MPG (Highway)' Weight='Weight (LBS)'
    Wheelbase='Wheelbase (IN)' Length='Length (IN)'
  ;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 15 replies
  • 2654 views
  • 1 like
  • 3 in conversation