Help using Base SAS procedures

how to export sas data to excel

Accepted Solution Solved
Reply
Regular Contributor
Posts: 161
Accepted Solution

how to export sas data to excel

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


Accepted Solutions
Solution
‎11-18-2011 01:49 PM
Super User
Super User
Posts: 6,500

how to export sas data to excel

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_) (Smiley Happy;

run;

View solution in original post


All Replies
Occasional Contributor
Posts: 13

how to export sas data to excel

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

Occasional Contributor
Posts: 13

how to export sas data to excel

Another method is to use Proc Export

PROC EXPORT Data=(you database)

          OUTFILE='(file location)'

                    REPLACE;

RUN;

Regular Contributor
Posts: 161

how to export sas data to excel

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

thanks

Valued Guide
Posts: 765

Re: how to export sas data to excel

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


Regular Contributor
Posts: 161

how to export sas data to excel

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

Trusted Advisor
Posts: 1,300

how to export sas data to excel

What OS are you running the SAS jobs on?

Regular Contributor
Posts: 161

how to export sas data to excel

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

I hope this helps

Super Contributor
Posts: 1,636

how to export sas data to excel

do you have excel on your computer?

Solution
‎11-18-2011 01:49 PM
Super User
Super User
Posts: 6,500

how to export sas data to excel

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_) (Smiley Happy;

run;

Regular Contributor
Posts: 161

how to export sas data to excel

thanks that did work

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 259 views
  • 0 likes
  • 6 in conversation