How to recover damaged SAS Data set (using PROC DATASETS REPAIR)

You might have encountered the following error when loading, updating to re-creating a sas data set.  “File WORK.XXXX.DATA is damaged. I/O processing did not complete” ERROR: File OLRSAS.RESULT.DATA is damaged. I/O processing did not complete. This is a most common situation where you need to repair a damaged data set: A system failure occurs while … Read more

How to Extract Last 4 Digits From A Numeric Variable in SAS

In SAS you can easily extract characters from a string using SUBSTR() or SUBSTRN() functions. But it only works with the character variable. To extract last 4 digits or any number of digits from a numeric variable, you need to convert the input from numeric variable to character variable in order to use substr function. … Read more

How to Populate Current Date and Datetime in SAS

You can easily populate the current date and datetime in SAS using today() and datetime() functions. More specifically, current date can be populated using today() function and date with time can be populated using datetime() function. We’re going to use the work data set “work.hightemp” to insert a new variable “date_now” with current date or … Read more

How to Print Data values into the SAS Log

SAS internally generates logs while executing SAS statements and writes them into the SAS LOG window or any specified external log file. The level of logging depends on the SAS system configuration or SAS options specified in the SAS program itself. But none of them prints actual data into the log window or log file.  … Read more