BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
R_A_G_
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

View solution in original post

10 REPLIES 10
iusing
Calcite | Level 5

File --> Export Data --> Choose your data set --> Choose your data location and format

iusing
Calcite | Level 5

Another method is to use Proc Export

PROC EXPORT Data=(you database)

          OUTFILE='(file location)'

                    REPLACE;

RUN;

R_A_G_
Calcite | Level 5

When I do this it saves all variables in one column. how can I chnage that?

thanks

MikeZdeb
Rhodochrosite | Level 12

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);


R_A_G_
Calcite | Level 5

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

FriedEgg
SAS Employee

What OS are you running the SAS jobs on?

R_A_G_
Calcite | Level 5

It's Windows 7 home premium, it's a 64 bit dual core processor.

I hope this helps

Linlin
Lapis Lazuli | Level 10

do you have excel on your computer?

Tom
Super User Tom
Super User

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;

R_A_G_
Calcite | Level 5

thanks that did work

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 10 replies
  • 2821 views
  • 0 likes
  • 6 in conversation