Date: Tue, 10 Apr 2012 20:25:12 -0400
Reply-To: Nat Wooding <nathani@VERIZON.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <nathani@VERIZON.NET>
Subject: Re: Importing a delimited file
Content-Type: text/plain; charset="US-ASCII"
I had time this evening to set up the following file:
1 2 a,b,c d,e,f
3 4 g,h,i j,k,l
Where I have tabs between the four fields (although this is not obvious for
the a,b,c and d,e,f.
The following code reads this with no problems and there are no issues with
the comma seperated characters not being
Enclosed in quotes. I used 9.2.
filename in 'C:\park\commatabtxt.txt' ;
infile in delimiter = '09'x;
informat num1 num2 8. Char1 char2 $8.;
input num1 num2 char1 char2;
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Kevin
Sent: Monday, April 09, 2012 8:00 AM
Subject: Importing a delimited file
I have received several delimited files that I need to read into SAS using
SAS 9.3 TS1M0 runnning on Windows XP Professonal 64-bit,
the file is tab delimited and some of the fields are string fields where
elements in that field are comma delimited. For example.
var1 var2 var3 var4
1 2 720.20,V87.5 85.47,83.2,93.81
Note that the number of delimited scores in var3 and var4 can range from 0
to 10, maybe even more.
The text below from a SAS technical report suggests that this problem would
using the DSD statement IF THE STRING
FIELD IS WITHIN QUOTATION MARKS, but
these string fields are not within quotation marks.
DSD (delimiter-sensitive data) option-Specifies that SAS should treat
delimiters within a data value as character data when the delimiters and the
data value are enclosed in quotation marks. As a result, SAS does not split
the string into multiple variables and the quotation marks are removed
before the variable is stored.
When the DSD option is specified and SAS encounters consecutive delimiters,
the software treats those delimiters as missing values. You can change the
default delimiter for the DSD option with the DELIMITER= option.
Any suggestions greatly appreciated.
Kevin F. Spratt, Ph.D.
Department of Orthopaedic Surgery
Dartmouth Medical School
One Medical Center Drive
Lebanon, NH USA 03756
(603) 653-6012 (voice)
(603) 653-6013 (fax)
Data is not information;
Information is not knowledge;
Knowledge is not understanding;
Understanding is not wisdom.
- Cliff Stoll and Gary Schubert