LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 11 Feb 2000 08:28:39 -0500
Reply-To:     Lary Jones <ljones@BINGHAMTON.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Lary Jones <ljones@BINGHAMTON.EDU>
Subject:      Re: DATA STEP: CSV AND LEADING SPACES
Comments: To: andy blissett <andy.blisset@ROYALMAIL.CO.UK>
In-Reply-To:  <950259704.804047@igateway.postoffice.co.uk>
Content-Type: text/plain; charset="us-ascii"; format=flowed

At 08:49 AM 2/11/2000 +0000, andy blissett wrote: >Hi.... > >I am reading in a data file that has delimeters (say a comma). When I read >in the file using the following example code: > >... >format a b c $char200.; >input a b c; >... >and the file loooks like this (note the leading spaces on each var) > > hello, mum, happy bday > >Then the variable a is set to 'hello' NOT ' Hello'

Andy,

Your problem is primarily that you specified a FORMAT (output), and not an INFORMAT. Also, I strongly recommend using the ATTRIB statement, by which you can specify the length, format, informat, and label of your variables in one place. Attrib provides good internal documentation. My version of your code would be: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 Data test; 2 infile datalines dlm=',' dsd; 3 attrib a b c 4 Length=$40 5 informat=$Char40. 6 format=$Char40. 7 ; 8 input a b c; 9 put a ; 10 datalines;

hello here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Notice that I do not need to add a format on the put statement. The specification of a format within the ATTRIB takes care of that.

Hope this helps, lary _______________________________________________________ Lary Jones % Statistical Computing Analyst Computing Services % .......................... Binghamton University % LJones@Binghamton.EDU Binghamton, NY 13902-6000 % (607) 777-2614


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