25 May 2014

Dealing with date values in SAS

SAS is a statistical analysis tool, which is used to analyze the data and generate a form of report. During this process of report generation, by default SAS will accept only numerical variable-values, whereas character variables are accepted only for grouping or classification of the data during analysis.

During the process of analysis, numerical values are accepted, and sometimes numbers might be in form of non-standard-values. These non-standards-values can be of datevalues, amount-values or might be time-values. SAS has the capability to read only standard characters or numeric-values. To read non-standard datavalues, SAS requires additional instructions, that is, it requires additional statements like Informat and Format-statements.

Where this Informat statement is used to read, non-standard data values from raw data and save them in the form of SAS understandable data within the dataset which is called as SAS data value. Whereas Format-statement is used to convert SAS data value into user readable data value.

In SAS, most of the datevalues will be in different formats, to read different types of date-values, SAS requires different types of informat statement. To know how to apply informat statement to a datevalue, first programmers need to know how date-values are read in SAS environment if Informat statement is applied.

How Date-values are read in SAS:

Date-values are always read and saved in the format-of-SAS-date-value. A SAS datevalue is a value-that represents the number of days from January 1st 1960, to the specific date. While taking the datevalues, SAS will perform calculations on dates ranging from A.D. 1582 to AD 19,900. Date-values that are before January 1st, 1960 are saved with negative signs, and date-values after 1st Jan 1960 are saved with positive signs.

Here are some examples of formatting date values, displaying different types of date formatting:


For example, if the SAS date value is, "25/09/2012", SAS accepts this date-values if informat statement is provided and saves as SAS-date-value. Programmer can convert this datevalue into required format using format-statement. But while converting this value into user readable-format, there are multiple-formats to convert. Here are some-formats described.

DDMMYY10.: This format will represent the datevalue in day, month and year format and by default these values are separated with slash symbol, where the total length of the value-remains 10 characters, because of "10." format-during-formatting.

DDMMYYB10.: This will represent the date-value in day, month and year, but these-values will be separated with blank spaces because of the "B" format that is present-during-format, where the total length of the value-remains about ten characters long.

DDMMYYC10.: This represent the datevalues in day, month and year-format but these values-will be separated with colon as separator due to "C" format-that is represented during formatting, where the final length of the values-remains-ten characters due to "10." format-in the-value.

DDMMYYP10.: This-format-also represents the datevalue in day, month and year-format, where the values-are-separated with points, because of the "P" format with the date-format and the length of the values will remain about ten characters in the value-due to "10." character length in the value.

DDMMYYD10.: This will represent the date-values in day, month and year format, where the values-are-separated with dash as separator, and the final length of the value-remains as ten characters long.

DOWNAMEw.: This will represent the day of the week, where the value-final length will be in the exact length that is produced by the programmer during formatting.

Date9.: This formatwill represent the month in characters, where the length of the value will be nine characters long.

MONNAMEw.: This will represent only month-value from the datavalue. Depending on the length given by the programmer, total length of the month will be assigned-by-format.

MMDDYY10.: This type of-format will be able to convert DDMMYY formatted date-value to month, day and year format.

YEARw.: This format-will be able to present only year from datevalue.

YYMMw.: This format-will be able to represent only year and month from the datevalue.

YYMMDDw.: This will be representing the year, month and day formatted date-value. Depending on the character length, length of the value-is assigned.

Conclusion: Thus, using these types of formats date-values can be formatted easily and saved to a dataset.

Clinnovo is a clinical innovation company. It is pioneer CRO industry in India. Clinnovo offers professional clinical research course , clinical data management course , SAS Courses and imaging training. Clinnovo has been serving different bio-pharma industries across the world with excellence and high quality. For more information contact at +91 9912868928, 040 64635501

No comments:

Post a Comment