Hello,
I need to export sas datasets to excel for multiple times.
what is the easiest code to use to do so
Thank you
RG
If you cannot get SAS to write to excel you could try creating CSV files instead.
Easiest way is a simple data step, but it will not output the variable names.
data _null_;
set have ;
file "want.csv" dsd lrecl=3000;
put (_all_) (:);
run;
File --> Export Data --> Choose your data set --> Choose your data location and format
Another method is to use Proc Export
PROC EXPORT Data=(you database)
OUTFILE='(file location)'
REPLACE;
RUN;
When I do this it saves all variables in one column. how can I chnage that?
thanks
hi ... some ideas (requires SAS/Access to PC file formats) ...
* excel file;
libname x 'z:\test.xls';
* file.name of spreadsheet;
data x.class;
set sashelp.class;
run;
libname x clear;
multiple times ...
%macro d2e (file,sheet,dset);
libname x "&file..xls";
data x.&sheet;
set &dset;
run;
libname x clear;
%mend;
* one spreadsheet, one file;
%d2e(z:\class,sheet1,sashelp.class);
* multiple spreadsheets, same file;
%d2e(z:\sashelp,air,sashelp.air);
%d2e(z:\sashelp,heart,sashelp.heart);
when I use this I get this error any idea why?
17 libname it2 'C:\CDM1\4K\MISspecified OUT\1000.xls';
ERROR: The EXCEL engine cannot be found.
ERROR: Error in the LIBNAME statement.
18 data it2.criterion;
19 set sashelp.criterion;
ERROR: File SASHELP.CRITERION.DATA does not exist.
20 run;
ERROR: Libname IT2 is not assigned.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
thanks
What OS are you running the SAS jobs on?
It's Windows 7 home premium, it's a 64 bit dual core processor.
I hope this helps
do you have excel on your computer?
If you cannot get SAS to write to excel you could try creating CSV files instead.
Easiest way is a simple data step, but it will not output the variable names.
data _null_;
set have ;
file "want.csv" dsd lrecl=3000;
put (_all_) (:);
run;
thanks that did work
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.