How to import raw data file in SAS?




I am loading data from a txt file into SAS using List Input, it has “,”(comma) as a delimiter. Now, the issue is there is two or more consecutive delimiters and due to this, I am not able to import it correctly. Ideally, these are considered as missing value for variables.

Input File:


I am using below code to perform this:

Data Test;
infile 'C:\Users\rahul\Desktop\test.txt' dlm=',';
Input EMP_Code Name$ Dept$ Salary;

Output of above code is as below, which is not correct.

Can you please help me to import this data and have missing values against consecutive delimiters?



If data set has two or more consecutive delimiters, use DSD option with Infile. See below code:

Data Test;
infile 'C:\Users\rahul\Desktop\test.txt' dlm=',' DSD;
Input EMP_Code Name$ Dept$ Salary;

Hope this helps!



As Sunil said, DSD (Delimiter Sensitive Data) options should fix your worries.

From the screenshot I gather you are using the old SAS Display Manager. You might want to try out SAS Enterprise Guide, which has all the capabilities of the old SAS interface but automates a lot of common processes like reading in data, querying, sorting, analysis, graphs, … Using EG you can save a lot of time by not having to worry about common tasks and program them from scratch.