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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 7027 views
  • 0 likes
  • 3 in conversation