BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14
So you recommend export to .csv file and not .txt file? Why?
Kurt_Bremser
Super User

I don't recommend anything but informing the recipient(s) of your exported data how to use it.

Documentation is not optional in a professional environment, it is required.

Ronein
Meteorite | Level 14
I dont need extra quotes but I afraid that without it the TXT(or CSV file) will not cut the columns successfully. What do you think?
ballardw
Super User

What does "cut the columns successfully" actually mean?

 

If you are worried about the position, i.e. creating fixed column data, then Export is not what you should use.

 


@Ronein wrote:
I dont need extra quotes but I afraid that without it the TXT(or CSV file) will not cut the columns successfully. What do you think?

 

Tom
Super User Tom
Super User

@Ronein wrote:
I dont need extra quotes but I afraid that without it the TXT(or CSV file) will not cut the columns successfully. What do you think?

To know whether or not the file can be properly read by some particular tool we need to know what tool you are using.  Most tools can read CSV files properly.  Most can also read similar files made with an other delimiter (in fact in a lot of countries that use comma as the decimal point indicate they routinely use semicolon as the delimiter instead of comma in "CSV" files).

 

I dislike using TAB as the delimiter in files because it makes the file hard to look at. And also if you open the file with a text editor it might replace the tabs with spaces to align the text to the next traditional tab stop and make the file unreadable.

 

If your data has a lot of commas (perhaps it has long descriptive text strings or using COMMA or DOLLAR format on some largish numbers) then I would use | as the delimiter.

 

Use a different extension on the file's name so that it does not accidentally get opened by whatever tool your machine is set to default to when it sees a CSV file.  The name of the file has NOTHING to do with the content.  It is just a suggestion to help the user make a quick judgement of what it MIGHT be.

 

proc export data=have file='myfile.txt' dbms=csv ;
  delimiter='|';
run;
Ronein
Meteorite | Level 14
I am a bit confused. You export to csv file ( dbms=csv)but used delimiter that is not comma?? As i understood csv file has comma delimiter by definition but here you export to csv file with other delimiter??
Ronein
Meteorite | Level 14
Okay. I saw now in google search:
Can CSV file have different delimiter?
A CSV file stores data in rows and the values in each row is separated with a separator, also known as a delimiter. Although the file is defined as Comma Separated Values, the delimiter could be anything. The most common delimiters are: a comma (,), a semicolon (;), a tab (\t), a space ( ) and a pipe (|).

My question- why did you choose csv and not txt? About type of delimiter you explained well why you choose delimiter thst is not tab.
Tom
Super User Tom
Super User

DBMS= is an OPTION on PROC EXPORT.  DBMS=CSV, DBMS=DLM and DBMS=TAB all generate the exact same type of TEXT file.  The only difference is the DEFAULT delimiter that is used.  You can override the default by including the DELIMITER= statement.

Ronein
Meteorite | Level 14
What type of file did you create? .csv or .txt? Why did you choose that your file name end with txt and not csv?


proc export data=have file='myfile.txt' dbms=csv ;
delimiter='|';
run;

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
  • 23 replies
  • 2343 views
  • 5 likes
  • 6 in conversation