Date: Fri, 17 Feb 2012 13:15:10 -0600
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: CSV file delimited with quotes and commas
Content-Type: text/plain; charset=ISO-8859-1
You can do either option. If you take the PROC EXPORT generated code, and
modify it, you can ask for a " " around any specific field.
There is a way to do this with ODS CSV as well, but I don't recall it off
the top of my head - if I come across it I'll let you know but I suspect
some of the others on the list will know it.
On Fri, Feb 17, 2012 at 12:57 PM, Abe <firstname.lastname@example.org> wrote:
> Hi there,
> I'm new to the list--though I've often browsed posts by other members. I
> work for a mid-sized bank in Utah where we use SAS heavily.
> One of the recent tasks I've been working on has me attempting to output
> a .csv file which has every field quote and comma delimited; I.e., ",".
> That is I want something every row to look something
> like: "0000232332","My Name","My Address","34433"
> I've tried two approaches so far, neither of which works for various
> PROC EXPORT DATA=work.datasett
> OUTFILE= "\\Server\Drive\DATA\Equifax\Name.csv"
> label DBMS=CSV REPLACE;
> ODS CSV FILE="\\Server\Drive\DATA\Equifax\Name.csv" options
> ODS HTML CLOSE;
> ods results=off;
> PROC PRINT DATA=work.datasett label noobs;
> ODS CSV CLOSE;
> ODS HTML;
> ods results=on;
> The problem with #1 is that the only fields which are quoted are those
> which have a comma in them--otherwise every field (regardless if it is
> character or numeric in the SAS dataset) is NOT quoted.
> The problem with #2 is that every field is quoted, but character fields
> are double quoted; I.e., """", as in ""My Name"". However, not specifying
> the delimiter option, or specifying the option of delimiter=',' only gives
> me quotes around those fields which SAS has "intelligently" determined to
> contain alpha-numeric data. Which leaves any fields which contain numeric
> data only but are defined as character fields in the SAS dataset as not
> quoted in the .csv file.
> Anyone have any thoughts on how I can accomplish my goal of getting
> *every* field in my .csv file quote-comma delimited?
> Warm regards,