Data Set

Create a SAS Data Set with the Datalines statement

In SAS you can create a data set that is neither based on existing data nor on an input file (.csv, .xlsx., etc.) with the datalines statement.

This example shows how to create a SAS data set with one character variable Name and one numeric variable Age. Firstly, you specify the name of your data set in the data statement (work.ds). Secondly, you define the variables of the data set with the input statement. Finally, after the datalines statement, you write the content of the data set.

data work.ds;
	
	/* Define the Variable Names and Types */
	input Name $ Age;
	
	/* Define the Content of the Data Set */
	datalines;
Maria 30
John 32
;
run;
SAS Datalines Statement

Instead of the datalines statement, you can use the cards statement. These statements are equivalent. If you want to read delimited data, see this example.

You can find the official SAS documentation about the datalines statement here.