BookmarkSubscribeRSS Feed
Pontus
Calcite | Level 5

I'm using EG version 7.13

At the end of a process, I want to export the results as a step in the process. The file should end up on my computer as an Excel file.

I would like to use a prompt to set the name of the exported file, for example "Data from 2017-03", where 2017-03 was entered in my prompt.

How do I do this?

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I don't use EG so not sure about the exact terminology, but prompts create macro variables do they not?  If so, and you just want a plain Excel file then:

proc export data=abc outtfile="C:\documents\&macro_variable.";
run;

Obviously paths and such like would need to set to your environment and the data= would need to be changed, and if you want nicer output switch to ods tagsets.excelxp.

rogerjdeangelis
Barite | Level 11
Using a pop up window to enter a dataset name to export to excel

If you get an error running this, contact your IT department and show them the error and
ask them to explain why your code did not work? Link back to this message https://goo.gl/frqxyy https://communities.sas.com/t5/SAS-Enterprise-Guide/Code-for-exporting-as-a-step-in-process/m-p/346954 HAVE (a dataset I want ro export to excel) SASHELP.CLASS WANT (enter the dataset name in a pop up window and export to excel) +----------------------------------------------+ |COMMAND ===> | +----------------------------------------------+ | | | ENTER DATASET NAME __sahelp.class<ENTER>__ | | | +----------------------------------------------+ d:/xls/class_dosubl.xlsx (19 obs) +------+-----------+------+------+ | | A | B | C | +------+-----------+------+------+ | | | | | | 1 | NAME | AGE| SEX | | 2 | Alfred | 14 | M | | 3 | Alice | 13 | F | | 4 | Barbara | 13 | F | | 5 | Carol | 14 | F | | 6 | Henry | 14 | M | | ... | ... | ... | ... | +------------------+------+------+ [CLASS} WORKING CODE window chose irow=5 rows=25 #5 @12 "Enter DSN " dsn $32. attr=underline; display chose; libname xel "d:/xls/class.xlsx"; data xel.class_dosubl; * _ _ _ ___ ___ | |_ _| |_(_) ___ _ __ / __|/ _ \| | | | | __| |/ _ \| '_ \ \__ \ (_) | | |_| | |_| | (_) | | | | |___/\___/|_|\__,_|\__|_|\___/|_| |_| ; * note you can pull these dosubl's out but This seems more flexible to me. 1. Save as one stored program or view? (untested) 2. Could sandwhich a set statement between the two dosubls 3. Could easily iterate either dosubl? 4. This encapsulates the code in one address space(depends on how sas compiles dosubl - but this is the most powerful implementation) data _null_; rc=dosubl(' data _null_; window chose irow=5 rows=25 #5 @12 "Enter DSN " dsn $32. attr=underline; display chose; call symputx("dsn",dsn); stop; run;quit; '); rc=dosubl(' libname xel "d:/xls/class.xlsx"; data xel.class_dosubl; set &dsn (keep=name sex age); run;quit; libname xel clear; '); stop; run;quit;
SASKiwi
PROC Star

Nice solution @rogerjdeangelis. Unfortunately the OP uses EG where WINDOW statements don't work as SAS runs either remotely or in a separate local session. Prompts are the EG alternative.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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