|
712 data _null_;
713 set sashelp.class;
714 file log dsd;
715 put (_all_)(~);
716 run;
"Alfred","M","14","69","112.5"
"Alice","F","13","56.5","84"
"Barbara","F","13","65.3","98"
"Carol","F","14","62.8","102.5"
"Henry","M","14","63.5","102.5"
"James","M","12","57.3","83"
"Jane","F","12","59.8","84.5"
"Janet","F","15","62.5","112.5"
"Jeffrey","M","13","62.5","84"
"John","M","12","59","99.5"
"Joyce","F","11","51.3","50.5"
"Judy","F","14","64.3","90"
"Louise","F","12","56.3","77"
"Mary","F","15","66.5","112"
"Philip","M","16","72","150"
"Robert","M","12","64.8","128"
"Ronald","M","15","67","133"
"Thomas","M","11","57.5","85"
"William","M","15","66.5","112"
On 2/17/12, Abe <abeburnett@gmail.com> 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
> reasons:
>
> (1)
> PROC EXPORT DATA=work.datasett
> OUTFILE= "\\Server\Drive\DATA\Equifax\Name.csv"
> label DBMS=CSV REPLACE;
> RUN;
>
> (2)
> ODS CSV FILE="\\Server\Drive\DATA\Equifax\Name.csv" options
> (delimiter='","');
> ODS HTML CLOSE;
> ods results=off;
> PROC PRINT DATA=work.datasett label noobs;
> RUN;
> 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,
>
> Abe
>
|