How to stop a runaway SAS process with *’;*”;*/;quit;run;

This post shows exactly how the SAS code snippet   *’;*”;*/;quit;run;  stops runaway SAS processes and how SAS EG uses this code to prevent them from occurring. A. How runaway processes occur on PC SAS  Beginning SAS users can easily forget to include semicolons or other components of a SAS command, which will result in an incomplete …

Continue reading »

Easily export a SAS data set to Excel with Enterprise Guide

step1_import

This post demonstrates how to easily export a SAS dataset from SAS Enterprise Guide to an Excel spreadsheet on your computer using the SAS Enterprise Guide Export wizard. Summary Exporting a SAS dataset from Enterprise Guide to an Excel spreadsheet on your computer is easy. Load the dataset into Enterprise Guide, select Send To > …

Continue reading »

How to easily import an Excel spreadsheet to Enterprise Guide

step1

How to easily import an Excel worksheet on your computer to a SAS dataset on a unix server using the SAS Enterprise Guide Import Data wizard. This example uses Enterprise Guide 4.2. Summary Importing an excel worksheet into SAS Enterprise Guide as a SAS dataset is easy. From Enterprise Guide, select File > Import Data, then …

Continue reading »

How to generate a data dictionary for a SAS data set

untitled

This blog entry shows you how to generate a data dictionary for a SAS data set and store it in a CSV file or an Excel spreadsheet.  The examples below use how this can be done using ODS, proc export, and libname. All the methods described below will create an export file that can easily be formatted …

Continue reading »

Transferring large (> 15 digit) numeric fields from Teradata to SAS

td18_example1

SAS numeric fields can only reliably store integers up to 15 signficant digits. When transferring numeric fields in Teradata of integers over 15 digits long to SAS, care must be taken to transfer the data in such a way that the accuracy of the least significant digits is not compromised. This blog post explains the issue and shows approaches …

Continue reading »

How to delay executing a SAS script using the sleep() function

Ever want to trigger a SAS script to run after peak hours (such as a script that includes an embedded Teradata data pull)? One way you can acheive this result is by using the sleep() function, as in the code below. Here’s what the parameters for the sleep() function represent: Parameter 1: how many “time …

Continue reading »

Useful Shortcut Keys for SAS Enterprise Guide

This post lists several handy shortcut keys when using SAS Enterprise Guide.   How would you like to: Immediately find a matching parentheis in complex nested SAS code? Immediately find the matching do and endkeywords for complex code? Go directly to a specified column in a 250 column dataset? Go directly to to row 2,250,153 …

Continue reading »

Efficiently determining the number of observations in a large SAS data set

The following approach determines the number of observations in a SAS dataset without reading through all the records in the dataset. It does so by fining the number of observations listed in the data set header.   Consider using this when detemining the number of observations for a large dataset.   NOTE: Be sure to …

Continue reading »

Setting Options for SAS Enterprise Guide

This blog entry shows how to set options, such as defaulting to your unix box, instead of Local, when executing code.     SAS Enterprise Guide allows you to personalize your Enterprise Guide though the use of many options. For a list of options go to Help > SAS Enterprise Guide Help > Index > …

Continue reading »

Pivoting” a SAS dataset using proc transpose

transpose_3

How to pivot from “narrow” data sets listing a single subject on multiple lines to “wide” data sets listing multiple listings for a single subject on a single line, and vice versa, using the SAS proc transpose option. At the end of this submission, I also show you how you can have the Enterprise Guide …

Continue reading »

Instantly Format Ugly SAS Code

 How to convert SAS code to an easy to read format using a simple SAS shortcut key. Summary Have you ever had to try to figure out poorly formatted SAS code? Have you ever wondered how to generate well formatted SAS code similar to code seen in SAS white papers?  Here’s how. Simply load the …

Continue reading »

How to find the specific SAS format you need

How to find the specific SAS format that you need         SAS provides thousands of pre-defined formats. Here are some starting points for finding the exact format you need: Go to SAS Help > Contents > Base SAS > SAS 9.2 Language Reference: Dictionary > Dictionary of Language Elements > Formats > …

Continue reading »

Several ways to quickly create sample SAS data sets

cards_dataset2

Many times you will want to create sample SAS datasets on the fly. Here are several ways to easily do so: Create a one-row table by setting variables directly Create multiple-row tables by including output statements Creating data by direct data entry using datalines Generating sample data from a do loop  1. Create a one-row …

Continue reading »

Deleting all data sets, views or formats in a SAS library

At times you will want to delete all objects, datasets, views, formats, or catalogs in a particular SAS library. Here’s how to do it. Delete all objects in a library The following SAS code will delete all objects in a SAS library (inlcuding datasets, views, catalogs, etc.). proc datasets library=work kill; quit;   Delete all …

Continue reading »

How to group a SAS data set by month chronologically

group_sas_dataset_by_month2

Here’s a simple way to group a SAS dataset by month in chronological order. Let’s say you are starting with the following SAS dataset (in this case, work.temp) and you want to get a count of these values by month.    The following code generates the desired result, by converting the date field to a …

Continue reading »

Create personalized errors, warnings, notes, and colored highlighting in SAS log files

sample error messages

This tip comes from Don’t Be a SAS Dinosaur, a great overall SAS reference available on the internet.   You can create personalized color-coded error, warning, and note messages in your SAS log file using the ERROR:, WARNING: and NOTE: key words. Note: These keywords are case sensitive The semi-colons are required Colors displayed in …

Continue reading »

Changing SAS data set and column names using proc datasets

It’s best not to use a data step simply to change the name of a SAS dataset or columns in a SAS dataset. This requires the entire dataset to be rewritten. Insead use proc datasets, which changes the names without needing to read the observations in the dataset.  Changing a dataset name using proc datasets This …

Continue reading »

SAS code to generate emails with file attachments

SAS allows you to generate emails through SAS code. It also allows you to include attachments of just about any type imaginable.  Example 1: Generating an email with a text file attachment The following code shows how to set up all the basic features of an email. Put your email address in the to: field, adjust …

Continue reading »

Transferring SAS data sets between your hard drive and unix

Sometimes you may have a SAS data set on your hard drive and want to load it to a unix server. Example: You receive a sas data set via email and want to work with it using Enterprise Guide. If you have PC SAS, there may be other times when you may want to copy …

Continue reading »

How to generate a report with subtotals by groups using SAS Enterprise Guide (proc report)

subtotal_group1

This post will introduce you to how SAS can generate a report that includes totals by groups. For more information on this topic, go to SAS Enterprise Guide, then select Help > Getting Started Tutorial > Begin Tutorial > Create and Modify a List Report. A.  Creating an initial dataset for your report Execute the …

Continue reading »

Getting Help for PC SAS and SAS Enterprise Guide

Here are some good resources for how to get help for SAS questions.  1. Google it Not only is this an obvious choice, but it is often the most productive choice too. The SAS institute provides many good resources for programming syntax, but often these reference sources are light on practical examples. Google search results …

Continue reading »

Accessing SAS Metadata using dictionary tables and sashelp views

A primer on mining information on all kinds of SAS metadata. Much of this information comes from Exploring DICTIONARY Tables and SASHELP Views by Kirk Paul Lafler.   Metadata available in SAS SAS stores it’s metadata in a special library called dictionary. (Note that it is the only SAS library with a name that can …

Continue reading »

How to re-order columns in a sas data set (without knowing their data types) using a retain statement

Typically, SAS users use a data statement such as format or informat or length or attrib (before the set statement) in order to have the columns in an output data set arranged in a certain order. However, a simpler approach is to use the retain statement, because it does not require you to know the …

Continue reading »

How to split screen the Enterprise Guide Program Screen

stacked

Often it is convenient to see two or more sections on the same SAS program at the same time when editing the code. To do this from your program in Enterprise Guide, simply right click on the Program Screen, then select Split. You can then select from the following choices: Stacked – One section of …

Continue reading »

Ways to delete SAS data sets

There are several ways of deleting one, several, or all sas datasets in a library. A. Using the SAS Enterprise Guide Interface   To delete SAS datasets using the Enterprise Guide interface, simply right click the name of one or more SAS datasets in the Server List, then select Delete.   B. Deleting specified data …

Continue reading »

How to configure SAS to make work data sets permanent

There will often be times when you will want to temporarily save your work data sets for subsequent analysis. For example, you may have a script with several intermediate transformations that you wish to troubleshoot before putting into production. Here’s how you can do it.   I. How to temporarily make ALL your work data …

Continue reading »

How to get confirmation of a SAS Professional Certification

How to confirm if someone has a SAS Professional Certification To confirm if someone has obtained a professional certification frm the SAS Institute, such as a SAS Certified Base Programmer for SAS 9 or a SAS Certified Advanced Programmer for SAS 9, you can look them up online in the SAS Global Certified Professional Directory. …

Continue reading »

SAS code to generate emails with file attachments

SAS allows you to generate emails through SAS code. It also allows you to include attachments of just about any type imaginable.       Example 1: Generating an email with a text file attachment   The following code shows how to set up all the basic features of an email. Put your email address …

Continue reading »

Working with Special Missing Null Values for SAS numeric variables

special_missingb10

Introduction SAS not only provides standard functionality for setting character or numeric fields to null, it also provides the ability to create specialized types of null values for numeric fields. For instance, you can create one type of null value to represent data that doesn’t exist vs. data that exists but is unknown vs. data …

Continue reading »

Dealing with the SAS error message “An unexpected error has occurred while accessing metadata”

The Problem Suppose you can successfully log into your unix account, but you get the following error message when trying to access the unix server from SAS Enterprise Guide: and possibly this second follow up message:   A Possible Solution If you get this error with a valid unix ID and password combination, you have …

Continue reading »

Home

This site is dedicated to new and experienced SAS practitioners.   See our SAS Tips section for practical tips on SAS programming and SAS Enterprise Guide.   See our SAS Recommended Books section for helpful reference books for using SAS.