Hello eveyone,
I am learning sas and I have seen to export the data into csv format using "Proc export" and "ODS CSV OR ODS CSVALL" code in the sas. But when I want to have to perfect format like below image. In the below image you can find that what I got This is what I getFig 1.I don't want this type of CSV file
But I want the CSV file in this format
Fig2. I want this type of CSV file format.
So instead of Fig1 I want fig2 type of CSV format.
Any suggestion would be commendable.
Thanks in advance
You have posted two photographs of some spreadsheet application.
A CSV file is a TEXT file. Please post examples of the TEXT file you generated and explain how you need it to be different.
Please copy and paste the first few lines of text from the CSV file into the box that opens when you click on the < / > icon in the forum editor so that its exact formatting will be preserved. Do not post photographs or screen grabs. Open the CSV file with a text editor or just read it with a SAS data step like this:
data _null_;
infile 'myfile.csv' obs=5 ;
input;
put _infile_;
run;
And copy the text from the SAS log.
What CODE are you running? PROC EXPORT uses the DATA= option to tell it which dataset you want to export.
ODS CSV just directs any output, so just run PROC PRINT to print the data you want. PROC PRINT also has a DATA= option.
The different methods have different best use cases.
ODS allows you to pipe different outputs to different files/sheets, add styles, graphs and formatting all within the same document (RTF, Word, PowerPoint).
Exports (PROC EXPORT) are just data dumps and it seems you want a data dump so ODS isn't your best choice in that case.
So use PROC EXPORT.
proc export data=sashelp.class outfile='/folders/myfolders/demo.csv' dbms=csv replace;run;
Change the path and data set as necessary.
@shailaja3 wrote:
Okay, Could you tell me where to mention the sas table to be converted as exact csv file?
I see infile is the path where we save the csv file then how do where do we take the sas table to be converted?
This is because the "c" in csv stands for "comma" (which is the standard), and SAS writes that to the file, while Excel thinks it only means "character", and uses a semicolon. By manually importing into Excel, and specifying the comma as separator, you will get it right.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.