- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
1. How Can I Convert sas dataset into "Pipe-delimited ASCII file with a .dat extension"?
2. To Create CSV file I am using below code but it's giving me excel file. So How Can I Convert sas dataset into "CSV"?
proc export data=inputdataset
outfile="&PROJROOT.\Analysis\&csvFileName"
dbms=csv replace;
run;
Thanks,
Adi
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
but one of my drug name has DEC03 so when it comes to that CSV file it is showing it gas 3-Dec. How can I solve this?
Your CSV file is fine. The problem is that you are using Excel to look at the file. A CSV file has no information about the the data types for a column. So the program that reads it has to set its own data types. Excel does a bad job of this.
Either open the file in some other application. Or if you must open it with Excel then start Excel first and use the menus to open the file so you get a step along the way to tell it what type of data each column contains. In my current version of Excel there is a menu option "From Text/CSV" under the "Data" menu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Your second example is NOT giving you an Excel file. It is creating a CSV file. You might be allowing your computer to automatically open Excel to read the file, but it is NOT an Excel file.
Did you read the manual on PROC EXPORT? Do you have specific questions about how to use it? Did you find the section for how to set the delimiter that is used? Show what you have tried and the resulting lines from the SAS log. Make sure to use the Insert Code icon to get a pop-up window where you can paste the lines so the forum doesn't try to format it as if it was text paragraphs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
One way:
proc export data=inputdataset outfile="&PROJROOT.\Analysis\filename.dat" dbms=dlm replace; dlm='|'; run;
Or use the Data export wizard.
You did not show the value of your "csvfilename" macro variable so replaced it with something without macros to have an idea what should go there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, that works well. Thank you for that.
I have one more question:
I am using below code for creating a CSV file:
proc export data=export
outfile="&PROJROOT.\Analysis\&csvFileName"
dbms=csv replace;
run;
but one of my drug name has DEC03 so when it comes to that CSV file it is showing it gas 3-Dec. How can I solve this?
Thank you in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
but one of my drug name has DEC03 so when it comes to that CSV file it is showing it gas 3-Dec. How can I solve this?
Your CSV file is fine. The problem is that you are using Excel to look at the file. A CSV file has no information about the the data types for a column. So the program that reads it has to set its own data types. Excel does a bad job of this.
Either open the file in some other application. Or if you must open it with Excel then start Excel first and use the menus to open the file so you get a step along the way to tell it what type of data each column contains. In my current version of Excel there is a menu option "From Text/CSV" under the "Data" menu.