SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tiri6
Fluorite | Level 6

Hi,

 

i have a problem with proc export, labels and quotes.

 

I need to export a file with a ":" inside the header field.

 

Now i'm using the classic proc export:

 

PROC EXPORT DATA= example
OUTFILE= "path\example.csv"
DBMS=DLM LABEL REPLACE;
DELIMITER='2C'x;
PUTNAMES=YES;
RUN;

 

And this is what i have:

 

"example:1" , "example:2" 

 

I just need: example:1 , example:2 without quotes but with the " : " inside the name of the field.

 

How can i do in order to export properly?

 

Thank you very much.

Marco

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

If you don't want quotes in the header row, write the data step yourself, or adapt the one that proc export created for you (take it from the log).

data have;
input example_1 example_2;
label
  example_1 = "example:1"
  example_2 = "example:2"
;
datalines;
1 2
3 4
;

data _null_;
set have;
file "/folders/myfolders/example.csv" dlm="," dsd;
if _n_ = 1 then put "example:1,example:2";
put example_1 example_2;
run;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

If you don't want quotes in the header row, write the data step yourself, or adapt the one that proc export created for you (take it from the log).

data have;
input example_1 example_2;
label
  example_1 = "example:1"
  example_2 = "example:2"
;
datalines;
1 2
3 4
;

data _null_;
set have;
file "/folders/myfolders/example.csv" dlm="," dsd;
if _n_ = 1 then put "example:1,example:2";
put example_1 example_2;
run;
Tiri6
Fluorite | Level 6
thank you very much. It was exactly what i needed. Have a nice day.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 2170 views
  • 0 likes
  • 2 in conversation