How to import data into SAS? Last Updated : 23 Jul, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report Entering Data Directly: You can enter numbers of lines of data directly in SAS program by using a DATALINES statement. The keywords are as follows: DATA: The DATA step always starts with a DATA statement. The purpose of the DATA statement is to tell SAS that you are creating a new data set i.e. outdata. DATA outdata; INPUT: To define the variables used in data set. INPUT age gender $ dept obs1 obs2 obs3; Dollar sign ($): To declare variable as a character. INPUT age gender $ dept obs1 obs2 obs3; DATALINES: To refer that lines following DATALINES statement a real data. DATALINES; PROC PRINT: To display out the contents of data set in output window. proc print; RUN: The DATA step ends with a RUN statement to run the complete code. run; Example: SQL DATA outdata; INPUT age gender $ dept obs1 obs2 obs3; DATALINES; 25 M 3 17 6 24 24 F 1 19 25 7 31 F 4 24 10 20 33 M 2 19 23 8 22 M 1 14 23 12 22 F 5 1 23 9 31 M 1 8 21 7 34 M 1 7 7 14 31 F 2 2 1 22 22 F 5 20 5 2 32 M 4 21 8 18 41 M 4 7 9 25 24 M 5 10 17 20 31 F 4 21 25 7 32 M 3 9 9 5 ; proc print; run; Output: You can also use CARDS instead of DATALINES. Both means the same. There is no difference between these two keywords. Example: SQL DATA outdata; INPUT age gender $ dept obs1 obs2 obs3; CARDS; 24 F 1 19 25 7 31 F 4 24 10 20 33 M 2 19 23 8 22 M 1 14 23 12 22 F 5 1 23 9 31 M 1 8 21 7 ; proc print; run; Output Reading Delimited Data: The default delimiter is blank. If you have a data file with other delimiters such as comma or tab you need to define the delimiter before defining the variables using INFILE and DLM = options. Syntax: Infile 'file-description' dlm=', ' While using tab delimiter, the syntax would be infile 'file-description' dlm='09'x While using colon delimiter, the syntax would be infile 'file-description' dlm=':' Example: SQL DATA outdata; INFILE Datalines dlm =", "; INPUT age gender $ dept obs1 obs2 obs3; Datalines; 34, M, 1, 7, 7, 14 31, F, 2, 2, 1, 22 22, F, 5, 20, 5, 2 32, M, 4, 21, 8, 18 41, M, 4, 7, 9, 25 24, M, 5, 10, 17, 20 ; proc print; run; Output: Comment More infoAdvertise with us Next Article Importing Data in MATLAB S ShubhamMaurya3 Follow Improve Article Tags : Software Engineering SAS Programming Similar Reads Importing Data in MATLAB MATLAB provides a simple way of importing data into a script using the importdata() function. This function takes various inputs and can be used in following forms. Method 1:This simply takes the data file and creates a suitable struct for the same within the script. Example 1: Matlab % MATLAB Code 2 min read SAS | Date Formats and Informats Informats is used to tell SAS how to read a variable whereas Formats is used to tell SAS how to display or write values of a variable. Informats is basically used when you read in sample data which is being created using CARDS/DATALINES statement or read or import data from either an external file ( 2 min read Define Import Options for Table in MATLAB The import tool lets you import into a table or another type of data. Take into consideration reading data from the sample spreadsheet file patients.xls into MATLAB as a table. Open the file with the Import Tool, select the output format and date range, and save. After you click the Import Selection 3 min read How to Create or Modify a Variable in SAS Programming? This will help you to create or modify a variable. It is common to define a new variable based on the existing variable. Let's create a dataset In the code below, we are creating a dataset named as Example1 which is going to store on WORK(temporary) library. In this dataset, there would be a variabl 2 min read SAS | How to specify a list of Variables? Suppose you have a list of variables. You don't want to type the name of each variable every time to define them within the function or array. You are looking for a shortcut to accomplish this task. Create a dataset with a list of variables SQL data dummy; input a1 a3 a4 a2 a6$ bs$ a5; cards; 2 1 3 2 min read SAS : How to Display Current Date? The today() function of SAS programming is basically used to generate current date. The format() function is used to display the format of the date in the specified format. In DD-MMM-YYYY format: Example: SQL data _null_; dt=today(); format dt yymmdd10.; put dt ; run; Output: In DDMMMYYYY format: Ex 1 min read Like