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

Hi I am trying to export a sas dataset to a delimited txt file using proc export but i am getting double quotes around the column names in the file. I am using label to print out column names without the '_' character . PFA the code

 

data OUTPUT_TABLE;
set OUTPUT_TABLE_1;
label External_Source='External Source'
External_Metric_Id='External Metric Id'
Metric_Name='Metric Name'
run;

 

/* Create and export flat file */

proc export data=OUTPUT_TABLE
outfile="/outbound/report/metric_&asOfMonth._&extractDate.-&extractTime..txt"
dbms=dlm label replace;
delimiter='|';
run;

 

the txt file has the column names as

"External Source"|"External Metric Id"|"Metric Name"|

 

is there a way to remove the "" from the labels while exporting to the file.?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

I don't believe there's a way in PROC EXPORT, you'll have to use a data step instead.

 

That being said, this is a common convention when exporting text files since it creates a data set that will also account for any embedded pipes. That's less likely to happen with pipes, but is useful when commas are the delimiters. 

 

https://stats.idre.ucla.edu/sas/faq/how-do-i-write-out-a-file-that-uses-commas-tabs-or-spaces-as-del...

 


@Anand08 wrote:

Hi I am trying to export a sas dataset to a delimited txt file using proc export but i am getting double quotes around the column names in the file. I am using label to print out column names without the '_' character . PFA the code

 

data OUTPUT_TABLE;
set OUTPUT_TABLE_1;
label External_Source='External Source'
External_Metric_Id='External Metric Id'
Metric_Name='Metric Name'
run;

 

/* Create and export flat file */

proc export data=OUTPUT_TABLE
outfile="/outbound/report/metric_&asOfMonth._&extractDate.-&extractTime..txt"
dbms=dlm label replace;
delimiter='|';
run;

 

the txt file has the column names as

"External Source"|"External Metric Id"|"Metric Name"|

 

is there a way to remove the "" from the labels while exporting to the file.?


 

View solution in original post

4 REPLIES 4
Community_Guide
SAS Moderator

Hello @Anand08,


Your question requires more details before experts can help. Can you revise your question to include more information? 

 

Review this checklist:

  • Specify a meaningful subject line for your topic.  Avoid generic subjects like "need help," "SAS query," or "urgent."
  • When appropriate, provide sample data in text or DATA step format.  See this article for one method you can use.
  • If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition. Use the Photos button to include the image in your message.
    use_buttons.png
  • It also helps to include an example (table or picture) of the result that you're trying to achieve.

To edit your original message, select the "blue gear" icon at the top of the message and select Edit Message.  From there you can adjust the title and add more details to the body of the message.  Or, simply reply to this message with any additional information you can supply.

 

edit_post.png

SAS experts are eager to help -- help them by providing as much detail as you can.

 

This prewritten response was triggered for you by fellow SAS Support Communities member @ballardw

.
Reeza
Super User

I don't believe there's a way in PROC EXPORT, you'll have to use a data step instead.

 

That being said, this is a common convention when exporting text files since it creates a data set that will also account for any embedded pipes. That's less likely to happen with pipes, but is useful when commas are the delimiters. 

 

https://stats.idre.ucla.edu/sas/faq/how-do-i-write-out-a-file-that-uses-commas-tabs-or-spaces-as-del...

 


@Anand08 wrote:

Hi I am trying to export a sas dataset to a delimited txt file using proc export but i am getting double quotes around the column names in the file. I am using label to print out column names without the '_' character . PFA the code

 

data OUTPUT_TABLE;
set OUTPUT_TABLE_1;
label External_Source='External Source'
External_Metric_Id='External Metric Id'
Metric_Name='Metric Name'
run;

 

/* Create and export flat file */

proc export data=OUTPUT_TABLE
outfile="/outbound/report/metric_&asOfMonth._&extractDate.-&extractTime..txt"
dbms=dlm label replace;
delimiter='|';
run;

 

the txt file has the column names as

"External Source"|"External Metric Id"|"Metric Name"|

 

is there a way to remove the "" from the labels while exporting to the file.?


 

Anand08
Calcite | Level 5

Thanks Reeza, I was able to use a data _null_ step to produce the desired result

Ksharp
Super User

Try add an option.

 

 

options validvarname=any;

proc export ...........

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 4512 views
  • 0 likes
  • 4 in conversation