BookmarkSubscribeRSS Feed
Nehemiah
Calcite | Level 5

Dear All

 

I have multiple(More than 10)date sets in Work Library and i want them into Single .CSV file With Multiple Sheets(each data set in different sheets on a Single .Csv File).

 

Can Anyone Help Me with Proper Code For above problem.

 

Thank you in Advance 

 

Regards 

Nehemiah

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

CSV files are plain text files. Not spreadsheet files. Therefore, you can not have multiple sheets in a single CSV file. It does not make sense.

 

I assume that what you actually want is to export data into multiple sheets in an .XLSX file?

Nehemiah
Calcite | Level 5

sir thanks for your solution.

 

sir l will explain in a clear manner.i have an excel file with some data..and my SAS Environment have permissions only for CSV files to import and export.so when i want to get the from excel to sas data set firstly i convert that excel into .csv and that file looked as excel..

so that's why i am asking multiple data sets into csv.  

 

thank you

 

 

 

 

andreas_lds
Jade | Level 19

This could be done with multiple data-null-steps using file-statement and the mod option. But i would not export datasets with different variables into one file.

PeterClemmensen
Tourmaline | Level 20

I Don't follow this exactly. Do you want to export all the data sets into a single .CSV file? I would not recommend that.

 

I think what you want to do is to export the data sets into multiple .CSV files and then import those into a single Excel Workbook with multiple sheets (1 for each .CSV File)).

PeterClemmensen
Tourmaline | Level 20

If my assumption is correct, you can do something like this and insert the relevant path. Then import the CSV Files to Excel

 

data a;set sashelp.class;run;
data b;set sashelp.class;run;
data c;set sashelp.class;run;

data _null_;
    set sashelp.vtable(where=(libname='WORK') keep=libname memname);
    call execute(compbl(cat(

    "Proc export data=",memname, "
        outfile='INSERT_PATH_HERE\", memname, ".csv'
        dbms=csv
        replace;
    run;"

    )));
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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