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
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
Hi,
One way:
data _null_;
set sashelp.cars (keep=make model type);
file 's:\temp\rob\temp.csv';
put '"' make '","' model '","' type '"';
run ;
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 " ";
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
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.
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 ;
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.
use my code .
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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.