- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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=10) NOOBS;
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
One way:
data _null_;
set sashelp.cars (keep=make model type);
file 's:\temp\rob\temp.csv';
put '"' make '","' model '","' type '"';
run ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 " ";
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
use my code .
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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