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
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?
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
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.
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)).
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;
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!
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.