output data set

Reply
Frequent Contributor
Posts: 91

output data set

Hi,

Can some one please help me to output the data generated from the following code(yt) to an excel data set?

proc iml;

d = 0.4;

call farmasim(yt, d) n=10 sigma=2 seed=123457;

print yt;

run;

Thanks:

SAS Employee
Posts: 1

Re: output data set

Hi malakaext,

As far as I know you can't directly export to Excel but there is a way to do that using PROC EXPORT.

The SAS/IML code that you should use is:

proc iml;

  start main;

       d = 0.4;

       call farmasim(yt, d) n=10 sigma=2 seed=123457;

       * Creates the dataset yt in the work library;

       create work.yt from yt;

       append from yt;

  finish main;

  * Execute the code defined in the main module;

  run main;

quit;

Once the dataset is in the work directory you can use PROC EXPORT. If you have SAS Interface to Microsoft products you will be able to export directly to Excel (*.xls file), if not you will be still able to export a CSV (directly readable in Excel). This is possible because SAS foundation includes SAS Interface to PC FILES.

In order to see if SAS Interface to Microsoft Office is included in your licence you can try to run this procedure and check in the log if you can find the interface:

proc setinit;

run;

* This procedure is going to create a CSV file in C: directory. If you want to create an Excel file you can change the extension to .xls;

proc export outfile="C:\yt.csv"

                 data = work.yt

                 replace;    

run;

Hope it helps!

Francesco

Ask a Question
Discussion stats
  • 1 reply
  • 201 views
  • 0 likes
  • 2 in conversation