Welcome to another post in the ‘BASE SAS Tutorial’ series. SAS is a very robust tool, capable of reading data from a variety of sources. In the next few posts, we will be discussing the various ways that data files are taken as an input into SAS. Let us start with text files or more specifically delimited text files.
So firstly, SAS considers spaces as the default value for the delimiter in a data file. Let us consider the piece of code below:
infile ‘/folders/myshortcuts/myFolder/Sample data – blank delimiter.txt’;
input gender $ Age Height Weight;
Screenshot of the data file being imported in the program:
The code provided above should work as it is in your SAS University software as long as there is a data file in the ‘myfolder’ location created during set up for SAS University Edition.
Let us quickly review the above information. The code is attempting to read a sample text file, which is space delimited. The file has 4 columns namely, Gender, Age, Height & Weight. Please note how the character variables are indicated in the input statement. Also please note, the infile statement. This statement is used to read in data into SAS programs. Users can provide options with this statement in order to change the delimiter depending on the file being imported.
Take time to review this the concepts shared in the post. You can create a sample data file and the use the program to test out your observations. 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.