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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 7 replies
  • 704 views
  • 1 like
  • 4 in conversation