Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read delimited data with datalines ?

Status
Not open for further replies.

chris93

Programmer
Jul 24, 2011
5
US
Hi all,

I am trying to read the following lines with observations seperated by commas and missing values.

Is it possible to use the dlm option and dsd in the input statement ?


data test1;
input n1 n2 n3 dlm =',' option ='dsd';
datalines;
23,34,345
23,4,45
2,3,5
3,4,545
345,,345
;
run;

proc print data = test1;
run;
 
Hi Chris,

Try placing the dsd option on the infile line. The dsd option will treat two consecutive delimiters as a missing value. I would also add the missover option in case you have missing values at the end of the line.

Code:
data test1;
infile datalines dsd missover  ;
input n1 n2 n3 ;
datalines;
23,34,345
23,4,45
2,3,5
3,4,545
345,,345
;
run;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top