Discover More Tips and Techniques on This Blog

Sending the SAS Log to an Output File

Here is the simple code which allows us to save the log file in the required location.

Use Proc printto procedure to save or print the log file.

filename dsn ‘C:\Documents and Settings\zzzzzzzzzzzz\Desktop\LOGfile.lst';

data dsn;
input patid implants;
datalines;
1 3
1 1
1 2
1 1
2 1
2 2
3 1
4 2
3 1
4 5
2 3
1 6
;
run;

proc printto log=dsn new;
run;


Example 2:
proc printto log="C:\temp\LOGLOG.log" print="C:\temp\LSTLST.lst" new;
run;


*Select only male students and age less than 16;
proc sql;
create table males as
select age, height, weight
from sashelp.class
where sex='M' and age lt 16
order by age;
quit;

*Get the descriptive statistics for height variable by age;

proc means data=males ;
by age;
var height;
output out=htstats mean=mean n=n std=sd median=med min=min max=max;
run;

PROC PRINTTO; *The second PROC PRINTTO step redirects output back to its default destination.;
run;


After PROC PRINTTO executes, all procedure output is sent to the alternate location until you execute another PROC PRINTTO statement or until your program or session ends.

SAS Date,Time and datetime functions

A Beginners Guide to SAS Date and Time Handling:

Abstract:

The SAS system provides a plethora of methods to handle date and time values. Correct date
computation became a very important subject when the world became aware of the Year 2000 issue. Computer users now realize most applications contain date and time variables. This beginning tutorial describes how the SAS system 1) stores dates, datetimes, and times; 2) reads date/time variables from "Raw Data Files" and from SAS data sets. It covers when and where to use SAS Informats and formats. Next it describes the easy methods to perform date/time arithmetic via date/time SAS functions.

The paper shows how SAS date Formats can be used in SAS Procedures such as PRINT, FREQ,
and CHART. Finally the tutorial will discuss Year 2000 issues and how SAS software helps you maintain correct date integrity and prevent future Y2k problems in the new millennium.

More can be read at: http://www.kellogg.northwestern.edu/researchcomputing/workshops/papers/finley_sugi25.pdf

How to Read, Write, and Manipulate SAS® Dates:

ABSTRACT:

No matter how long you’ve been programming in SAS, using and manipulating dates still seems to require effort.

Learn all about SAS dates, the different ways they can be presented, and how to make them useful. This paper includes excellent examples in dealing with raw input dates, functions to manage dates, and outputting SAS dates into other formats. Included is all the date information you will need: date and time functions, Informats, formats, and arithmetic operations.

WHAT IS A SAS DATE?
A date is unique within SAS programming. It is neither a character value nor a typical numeric. It is a special case of a numeric variable. In other words, a SAS date is a special representation of a calendar date. Unlike dates in many other languages, SAS has a specific numeric value assigned to each day. The starting point for all SAS dates is January 1st, 1960 and is represented as day zero (0). All previous and subsequent dates are represented with numeric values plus (+) or minus (-) from this starting point. The simplicity of the approach is there will never be a point in the past (since the start of the Gregorian calendar) or future that can not be represented by a
number.

More can be read at: http://analytics.ncsu.edu/sesug/2008/HOW-063.pdf

Working With SAS® System Date and Time Functions

SAS Date, Time, and Datetime Functions

Disclosure:

In the spirit of transparency and innovation, I want to share that some of the content on this blog is generated with the assistance of ChatGPT, an AI language model developed by OpenAI. While I use this tool to help brainstorm ideas and draft content, every post is carefully reviewed, edited, and personalized by me to ensure it aligns with my voice, values, and the needs of my readers. My goal is to provide you with accurate, valuable, and engaging content, and I believe that using AI as a creative aid helps achieve that. If you have any questions or feedback about this approach, feel free to reach out. Your trust and satisfaction are my top priorities.