BookmarkSubscribeRSS Feed
shailaja3
Fluorite | Level 6

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 getThis is what I getFig 1.I don't want this type of CSV file But I want the CSV file in this formatBut 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

 

5 REPLIES 5
Tom
Super User Tom
Super User

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.

shailaja3
Fluorite | Level 6
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?
Tom
Super User Tom
Super User

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.

Reeza
Super User

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?

 

Kurt_Bremser
Super User

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.

sas-innovate-white.png

Register Today!

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.

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
  • 5 replies
  • 1364 views
  • 0 likes
  • 4 in conversation