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 1997, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 12 Feb 1997 17:14:15 GMT
Reply-To:     Philip Holland <phil.holland@BCS.ORG.UK>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Philip Holland <phil.holland@BCS.ORG.UK>
Organization: -
Subject:      Re: Delimiter File Write
Content-Type: text/plain; charset=us-ascii

Robert Schechter <robert_schechter@MERCK.COM> wrote: >OK, we've had an ongoing thread on the INFILE DLM option. Anyone had >experience creating an output delimited flat-file? Something as easy as >a DLM for the FILE statement. I'm currently creating a flat file within >a DATA _NULL_ SAS6.08 IBM/MVS PUT statements. My customer would like the >"same file, only comma delimited". I'd rather not add "," between each >variable as I'm sure they'll keep changing their minds. Any >suggestions? > >Thanks, >Robert_Schechter@MERCK.COM >Maxim Group SAS Consultant


I found this code in a SAS Technical Support note (TS501.TXT), and it seems to be a pretty good fit to your problem:


This code does not require typing in the list of variable names on the PUT statement, which can be very time-consuming, but it does force the variable ordering to be grouped by variable type. For instance, in this example, we will have an external file with all of our character variables at the beginning of the record in the order that they appear in the SAS dataset, followed by all of the numeric variables.

DATA A; INPUT A $ B C $ D; CARDS; W 1 X 2 Y 3 Z 4 RUN;

DATA _NULL_; SET A; /*set your sas data set*/ FILE 'EXTERNAL-FILE'; /*name your external file here*/ ARRAY CHAR (*) $ _CHARACTER_; /*assigns all your character vars to this array*/ ARRAY NUM (*) _NUMERIC_; /*assigns all your numeric vars to this array*/ PUT (CHAR(*)) ($ +(-1) ',') @; PUT (NUM(*)) ( +(-1) ','); RUN;

This code would result in the following two lines being written to the external file: W,X,1,2 Y,Z,3,4


You could always store a comma, or whatever delimiter you want, in a macro variable and then replace ',' with "&mac" in the code above?

HTH...............Philip R Holland <> Holland Numerics Ltd Royston, Herts, UK mobile: +44-(0)850-295556

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