The SAS Output Delivery System and reporting techniques

unexpected result using PROC PRINT with ODS CSV

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 89
Accepted Solution

unexpected result using PROC PRINT with ODS CSV

I use proc print (as a standard sas tool) below  to create a csv file (on mainframe):                                          

ODS CSV FILE='c:\temp\test.csv'  OPTIONS(DELIMITER=';') RS=NONE;                 

PROC PRINT DATA=F.COPBAL(obs=10NOOBS;

where c002_account_nbr like '571%E%'

FORMAT   C008_Non_Gaap  $CHAR2.;  

RUN;                                                        

ODS CSV CLOSE;

Although the second column is charachter some records are not with " " (when it does not start with a letter)!!

"BE01";"V443000000";"Cha...

"BE01";1200000000;"Net ...

"BE03";5710000E05;"Ban.....

Has anyone a solution ??

GreetZ,

Herman


Accepted Solutions
Solution
‎04-09-2014 12:11 PM
SAS Super FREQ
Posts: 8,864

Re: unexpected result using PROC PRINT with ODS CSV

Hi, what version of SAS are you running. I thought that ODS CSV had a "quote_by_type" sub option that you could specify. Take a look at the attached screen shot. I thought quote_by_type was implemented in SAS 9.2 or 9.3. The doc='Help' suboption should put the list of options that you can use with your version of ODS CSV in the SAS log. Note how I used delimiter= to make the delimiter a tilde (~).

 

cynthia


show_quote_by_type.png

View solution in original post


All Replies
Super User
Super User
Posts: 7,942

Re: unexpected result using PROC PRINT with ODS CSV

Hi,

One way:

data _null_;         

set sashelp.cars (keep=make model type);

file 's:\temp\rob\temp.csv';

put '"' make '","' model '","' type '"';

run ;

Super User
Super User
Posts: 7,942

Re: unexpected result using PROC PRINT with ODS CSV

Sorry, just to add as I don't feel I answered your question, the ods csv is a tagset, which you can find by right clicking on Results in Results window and selecting templates.  Under one of the folders you will find Tagsets and in there one called csv.  If you double click to open the code you will see all the options you can use with that tagset.  I think the one you are looking for is:  quoted_columns:

...

        putlog                                                              

               "     Will be deprecated in a future release when it is no long

er needed.";                                                                 

         putlog " ";                                                         

         putlog "Quoted_columns:   Default Value ''";                        

         putlog                                                              

               "     A list of column numbers that indicate which values shoul

d be quoted";                                                                

         putlog "     ie. Quoted_columns=""123""";                           

         putlog " ";                                                         

         putlog "Bylines:   Default Value: No";                              

         putlog "     If yes bylines will be printed";                       

         putlog " ";                                                        

Super User
Posts: 10,020

Re: unexpected result using PROC PRINT with ODS CSV

Do you have to have quote around it ?

data have;
infile cards dlm=';' dsd;
input (a b c) (: $20.);
cards4;
"BE01";"V443000000";"Cha.."
"BE01";1200000000;"Net ..."
"BE03";5710000E05;"Ban."
;;;;
run;

data _null_;
 set have;
 file 'c:\temp\x.csv' dsd dlm=';';
 put a ~ b ~ c ~;
run;

Xia Keshan

Frequent Contributor
Posts: 89

Re: unexpected result using PROC PRINT with ODS CSV

indeed . . . an quote around CHAR vars and no quote's around NUM vars (and using the format of it)

the 3 lines I have is the output csv file where you see that although a column is defined as char,  sas something use no quotes

H.

Super User
Posts: 10,020

Re: unexpected result using PROC PRINT with ODS CSV

But That doesn't affect you using csv file. If you use proc export ,will also get the same result . not know about sas macro %ds2csv() .

no quote : put a b c ;

Frequent Contributor
Posts: 89

Re: unexpected result using PROC PRINT with ODS CSV

proc export does not work on mainframe,

indeed now I am using %DS2CSV but I am strugling with sepchar:  on pc I have 3B for ; (is perfect) but can't find the value to use on mainframe

H.

Super User
Posts: 10,020

Re: unexpected result using PROC PRINT with ODS CSV

use my code .

Solution
‎04-09-2014 12:11 PM
SAS Super FREQ
Posts: 8,864

Re: unexpected result using PROC PRINT with ODS CSV

Hi, what version of SAS are you running. I thought that ODS CSV had a "quote_by_type" sub option that you could specify. Take a look at the attached screen shot. I thought quote_by_type was implemented in SAS 9.2 or 9.3. The doc='Help' suboption should put the list of options that you can use with your version of ODS CSV in the SAS log. Note how I used delimiter= to make the delimiter a tilde (~).

 

cynthia


show_quote_by_type.png
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 908 views
  • 0 likes
  • 4 in conversation