BASE SAS Programming – Import Delimited Files




Hello all. Nice to have you going strong with our “BASE SAS Tutorial’ series. In the previous post, we looked at how the SAS tool reads text files with space delimiter. Spaces being the default delimiter for the tool. However, in the real world scenario, data is never provided from any source with space as the delimiter value. Luckily, SAS allows a great deal of flexibility to read delimited files with a variety of options of different elements. Let us look at the sample program below where we try to import the same data as in the previous post, but with the “/” character as the delimiter instead of the the default space.

Data sample1;
infile ‘/folders/myshortcuts/myFolder/Sample data – delimiter.txt’ dlm = “/”;
input gender $ Age Height Weight;
run;

Snapshot of the data contained in the file;

The output of the code as it would appear in the log and the output tab:

Log:

Output Tab:

This is the most common method of importing data into any SAS tool that is available for end users. It is important to understand clearly how the simple code shared in this post is working so that it can be scaled for data files with more number of columns and complications. Please try it out and share your experience in the comments below. Please find relevant reference books in the sidebar, if you should want to purchase the same for further studying. Please sign up for our newsletter, so that we may keep you posted on the latest activity on our website and Youtube channel.