BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ssmith
Fluorite | Level 6

Hello!

I am attempting to print a log and list file programmatically using sas 9.3 to an existing script. Currently, my script works fine, and has been used for years, so I am confident in it. However, when I add a printto procedure at the end of this script, my list file is of size 0kb, and I get a log file saved in the correct lcoation, with the following output:

 

NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1970  
1971  /*This last proc print reassigns the output back to the output window*/
1972  proc printto;
1973  run;

 

The problem is that there is a whole bunch more to the log than this (here is a snippet):

1948
1949  proc sort data=testing;
1950  by dno ttno units;
1951

NOTE: There were 2 observations read from the data set WORK.TESTING.
NOTE: The data set WORK.TESTING has 2 observations and 25 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


1952  proc compare base=test.origcheck compare=work.testing /*NOPRINT*/
1953  out=result outbase outcomp outdif /*outnoequal*/;
1954     id ttno units;
1955     title 'Comparing Observations that Have Matching TTNOs';
1956  run;

NOTE: There were 2 observations read from the data set TEST.ORIGCHECK.
NOTE: There were 2 observations read from the data set WORK.TESTING.
NOTE: The data set WORK.RESULT has 6 observations and 27 variables.
NOTE: PROCEDURE COMPARE used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


1957
1958  proc print data=result noobs;
1959     by ttno units;
1960     id ttno units;
1961     title 'The Output Data Set RESULT';
1962  run;

NOTE: There were 6 observations read from the data set WORK.RESULT.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


1963
1964
1965
1966  /*This needs to be an absolute path, not the relative S: drive*/
1967  /*This is saving a copy of the log file and the output to a directory for later varification if need be*/
1968  proc printto log="S:\SS\Update logs\&deal-&update..log" print="S:\SS\Update
1968! logs\&deal-&update..lst" new;
1969  run;

NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

 And finally, here is the last bit of the script, where I am attempting to save the log and output:

proc sort data=testing;
by dno ttno units;

proc compare base=test.origcheck compare=work.testing /*NOPRINT*/
out=result outbase outcomp outdif /*outnoequal*/;
   id ttno units;
   title 'Comparing Observations that Have Matching TTNOs';
run;

proc print data=result noobs;
   by ttno units;
   id ttno units;
   title 'The Output Data Set RESULT';
run;



/*This needs to be an absolute path, not the relative S: drive*/
/*This is saving a copy of the log file and the output to a directory for later varification if need be*/
proc printto log="S:\SS\Update logs\&deal-&update..log" print="S:\SS\Update logs\&deal-&update..lst" new; 
run; 

/*This last proc print reassigns the output back to the output window*/
proc printto;
run;

This proc printto seemed really simple at first, but I am at a loss as to what I am doing wrong here? To recap: the files are created, with the correct names and in the correct location, but the list file is empty, and the log file is incomplete. 

 

Any help would be greatly appreciated! 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

When you add NEW to PROC PRINTTO, it wipes out the files that you are writing to, and starts with a clean slate.

 

So there should be one PROC PRINTTO (early) that uses NEW.  It should appear BEFORE all the results that you want to redirect to the new locations.  Then all subsequent PROC PRINTTOs should remove NEW.

View solution in original post

4 REPLIES 4
art297
Opal | Level 21

Not sure if I follow what you've done, but it appears like you are calling proc printo multiple times, rather than calling it once and that only calling it again when you no longer want to capture the log.

 

Art, CEO, AnalystFinder.com

 

nehalsanghvi
Pyrite | Level 9

The first proc printto that redirects the log to a file needs to be at the beginning of your program. Then at the end, you redirect it back to the log window with the second proc printto.

Astounding
PROC Star

When you add NEW to PROC PRINTTO, it wipes out the files that you are writing to, and starts with a clean slate.

 

So there should be one PROC PRINTTO (early) that uses NEW.  It should appear BEFORE all the results that you want to redirect to the new locations.  Then all subsequent PROC PRINTTOs should remove NEW.

ssmith
Fluorite | Level 6

Art, nehalsanghvi, astounding, thank you very much. I somehow misunderstood that while reading the documentation. It seems to work just fine now. Thanks again!

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 3856 views
  • 1 like
  • 4 in conversation