08-24-2016 01:48 PM
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.
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 $
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).
08-24-2016 02:34 PM
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 replace; run;
Assuming you have headers for the columns in the first row. You might need to set guessingrows.
08-24-2016 03:49 PM
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.