LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (April 2012, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
In-Reply-To:  <7.0.1.0.2.20120409075022.0b9fbfc8@Dartmouth.Edu>
Content-Type: text/plain; charset="US-ASCII"

Kevin

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.

Nat

filename in 'C:\park\commatabtxt.txt' ; Data want; infile in delimiter = '09'x; informat num1 num2 8. Char1 char2 $8.; input num1 num2 char1 char2; run;

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Kevin F. Spratt Sent: Monday, April 09, 2012 8:00 AM To: SAS-L@LISTSERV.UGA.EDU 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 be handled 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 DHMC Lebanon, NH USA 03756 (603) 653-6012 (voice) (603) 653-6013 (fax) Kevin.F.Spratt@Dartmouth.Edu (e-mail)

Data is not information; Information is not knowledge; Knowledge is not understanding; Understanding is not wisdom.

- Cliff Stoll and Gary Schubert

_______________________________________________________________________


Back to: Top of message | Previous page | Main SAS-L page