DATA Step, Macro, Functions and more

Reading raw data separated by delimiter

New Contributor
Posts: 2

Reading raw data separated by delimiter

Hi All,

While going through The Little SAS Book, it is mentioned that if we are reading raw data file using list input then in case of character data there shouldn't be any embedded space.

My question here is that  this limitation is applicable only when the delimiter is blank(default delimiter,In this case we have to use option dsd to read character data with embedded space).

I am having a data set where values in raw data file are comma seperated and in character data there is embedded space. But when i am trying to read the data with the following code,it is generating correct output.

data sales;
infile 'E:\SAS data\Data\base data set\lwprg1\sales.csv' dlm = ',';
length Job_Designation $ 20;
input ID First_Name $ Last_Name $ Gender $ Salary Job_Designation $ Country $
Birth_DateSmiley Very Happyate9.

Please let me know whether my understanding is correct or not and help me in clearing my confusion.

Attaching screenshot of sample raw data file(Embedded space data has been highlighted).

New Contributor
Posts: 3

Re: Reading raw data separated by delimiter

Posted in reply to ashish_197

There should not be an issue with using spaces, because the comma is the delimiter.


Alternatively you could use proc import instead:

* Import the file;
proc import datafile = 'E:\SAS data\Data\base data set\lwprg1\sales.csv'
	out = sales

Assuming you have headers for the columns in the first row. You might need to set guessingrows.

Super User
Posts: 13,508

Re: Reading raw data separated by delimiter

Posted in reply to ashish_197

However any delimited data does have a potential issue with embedded delimiter. Hence you see most applications that create commas separated files, csv, will put quotes around text with commas as part of a value (if the app doesn't do that for all character data). Which is where the SAS Infile option DSD comes into play.





Ask a Question
Discussion stats
  • 2 replies
  • 1 like
  • 3 in conversation