BookmarkSubscribeRSS Feed
ashish_197
Calcite | Level 5

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_Date:Date9.
Hire_date:ddmmyy10.;
run;

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).


dataset.PNG
2 REPLIES 2
CR204
Calcite | Level 5

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.

ballardw
Super User

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.

 

 

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2154 views
  • 1 like
  • 3 in conversation