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

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:

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

See the section "Creating a SAS Data Set from SAS/IML Vectors" in the following blog post: Writing data from a matrix to a SAS data set - The DO Loop

After it is in a SAS data set, use PROC EXPORT to convert to a format that Excel can read. For an example, see http://support.sas.com/resources/papers/proceedings12/247-2012.pdf

View solution in original post

4 REPLIES 4
Rick_SAS
SAS Super FREQ

See the section "Creating a SAS Data Set from SAS/IML Vectors" in the following blog post: Writing data from a matrix to a SAS data set - The DO Loop

After it is in a SAS data set, use PROC EXPORT to convert to a format that Excel can read. For an example, see http://support.sas.com/resources/papers/proceedings12/247-2012.pdf

malakaext
Calcite | Level 5

Thank you very much.

When I ran the following code, it gave me an error. Could you please help me with that.

CODE:

proc iml;

d = 0.4;

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

create MyData var {yt}; /** create data set **/

append;       /** write data in vectors **/

close MyData; /** close the data set **/

proc print data=MyData;

run;

LIBNAME dat "c:\sas\data\";

PROC EXPORT DATA=MyData;

            OUTFILE="F:\data\test.csv"

            DBMS=csv REPLACE;

RUN;

ERROR:

788  LIBNAME dat "c:\sas\data\";

NOTE: Library DAT does not exist.

789

790  PROC EXPORT DATA=MyData;

ERROR: FILE= or TABLE= is required and must be specified.

NOTE: The SAS System stopped processing this step because of errors.

Thanks

Linlin
Lapis Lazuli | Level 10

Hi,

You don't need this line:  /*LIBNAME dat "c:\sas\data\"; */ and the ";" after "PROC EXPORT DATA=MyData" is not needed.

proc iml;

d = 0.4;

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

create MyData var {yt}; /** create data set **/

append;       /** write data in vectors **/

close MyData; /** close the data set **/

proc print data=MyData;

run;

PROC EXPORT DATA=MyData

            OUTFILE="F:\data\test.csv"

            DBMS=csv REPLACE;

RUN;

malakaext
Calcite | Level 5

Thank you very much... I figured it out too. Anyway I really appreciate ur answer.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

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
  • 4 replies
  • 887 views
  • 3 likes
  • 3 in conversation