BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Pobel1
Calcite | Level 5

Hi,

Here is an example using ODS CSVALL to convert SAS to CSV file:

data test;
    x="aaaa"; output;
    x="+1"; output;
    x="Okay"; output;
run;
 
ods csvall file="test.csv";
proc print data=test noobs;
run;
ods csvall close;
 
And in the CSV file, the "+" sign is gone:
x
aaaa
1
Okay

Question: Is there a way to keep the "+" in the CSV file?
 
Thanks in advance!
1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

According to Maxim 1:

 

data test;
    x="aaaa"; output;
    x="+1"; output;
    x="Okay"; output;
run;
 
ods csvall file="test.csv" options(DOC="HELP" Quoted_columns="1");

title "Test title!!";
proc print data=test noobs;
run;
ods csvall close;
 

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

7 REPLIES 7
Pobel1
Calcite | Level 5

It's the same when using NOTEPAD to open the file:

Pobel1_0-1688971076134.png

 

Kurt_Bremser
Super User

If your goal is to have a simple csv file, don't use ODS. Both of these methods work:

data _null_;
set test;
file "~/test1.csv";
if _n_ = 1 then put "x";
put x;
run;

proc export
  data=test
  file="~/test2.csv"
  dbms=csv
  replace
;
run;

And will perform MUCH better with larger datasets.

Pobel1
Calcite | Level 5

Thanks!
Yes, both of the methods work. Just I also need to add a title to the CSV file.

 

yabwon
Onyx | Level 15

According to Maxim 1:

 

data test;
    x="aaaa"; output;
    x="+1"; output;
    x="Okay"; output;
run;
 
ods csvall file="test.csv" options(DOC="HELP" Quoted_columns="1");

title "Test title!!";
proc print data=test noobs;
run;
ods csvall close;
 

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Pobel1
Calcite | Level 5

Cool!!
Thank you Bart!

Tom
Super User Tom
Super User

That is a BUG in the CSVALL ODS destination.  You should report it to SAS support.

 

Not only does it not generate the proper CSV file, it also seems to have some lasting impact on the normal HTML output used in the RESULT window in Display Manager.

 

If I run this code once:

data test;
    x="aaaa"; output;
    x="+1.0"; output;
    x="Okay"; output;
run;
filename csv temp;
ods csvall file=csv;
proc print data=test noobs;
run;
ods csvall close;

data _null_;
  infile csv ;
  input;
  list;
run;

The PROC PRINT displayed in the Results Window looks normal:

Tom_0-1688992017449.png

If I then run the same code a second time the Results output has switched to using some monospaces font. And the output looks like the output previously sent to CSVALL, with the missing + and the extra unneeded quotes around the other value.

Tom_1-1688992181050.png

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 984 views
  • 1 like
  • 4 in conversation