BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jaheuk
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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

8 REPLIES 8
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

One way:

data _null_;         

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

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

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

run ;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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 " ";                                                        

Ksharp
Super User

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

Jaheuk
Obsidian | Level 7

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.

Ksharp
Super User

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 ;

Jaheuk
Obsidian | Level 7

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.

Cynthia_sas
SAS Super FREQ

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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