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

Hi all - Being new to SAS, I have noticed that the PUTLOG and PUT statements seem to be syntactically similar and accomplish the same goals when trying to debug a program for logic errors. What is the main difference between these two statements? Should beginner programmers use one over the other? Thank you - Dan

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

In a data step you can write output to file or another output destination. The PUT will write to any of the open destinations but putlog only writes to the log.

 

A brief example program.

data _null_;
   file print;
   put 'This will go to the default output destination';
   putlog 'This should only appear in the log';
run;

Copy the above code into your SAS session and run it. You will likely not find "This will go the default output destination" in the log but it should be in the Results or Listing output window depending on how you are running your session. The Putlog statement will.

 

Many years ago, and still do occasionally, use Put statements to write text to specific types of file formats such as text that needs to start in specific columns or lines on a logical page.

View solution in original post

2 REPLIES 2
ballardw
Super User

In a data step you can write output to file or another output destination. The PUT will write to any of the open destinations but putlog only writes to the log.

 

A brief example program.

data _null_;
   file print;
   put 'This will go to the default output destination';
   putlog 'This should only appear in the log';
run;

Copy the above code into your SAS session and run it. You will likely not find "This will go the default output destination" in the log but it should be in the Results or Listing output window depending on how you are running your session. The Putlog statement will.

 

Many years ago, and still do occasionally, use Put statements to write text to specific types of file formats such as text that needs to start in specific columns or lines on a logical page.

danchild
Calcite | Level 5
Thank you very much!

Welcome to the Certification Community

 

This is a knowledge-sharing community for SAS Certified Professionals and anyone who wants to learn more about becoming SAS Certified. Ask questions and get answers fast. Share with others who are interested in certification and who are studying for certifications.To get the most from your community experience, use these getting-started resources:

Community Do's and Don'ts
How to add SAS syntax to your post
How to get fast, helpful answers

 

Why Get SAS Certified.jpg

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 4656 views
  • 4 likes
  • 2 in conversation