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

 

Dear experst;

 

How to call .exe and get as SAS dataset. when you run the .exe it gives me excel output and I want to save the excel file and process the file using SAS.

 

 data download;

infile 'myfile.exe' pipe;

length A $50;

input A$ B c; * read from output;

putlog _infile_; * show it in the log;

 run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
tekish
Quartz | Level 8

/****************************************************/

/* SAVE EXCEL FILES FROM DOWNLOAD */

/***************************************************/

%LET OUT=C:\DOWNLOAD\;

%LET REPORT=BOOK1;

FILENAME COMMANDS DDE 'EXCEL|SYSTEM';

RUN;

%LET FILE = &OUT.&REPORT..XLSX;

RUN;

DATA _NULL_;

FILE COMMANDS;

PUT "[SAVE.AS(""&FILE"")]";

PUT '[QUIT]';

RUN;

View solution in original post

10 REPLIES 10
tekish
Quartz | Level 8

KurtBremser,

 

It is running with out error, but my biggest concern is how do I save the excel output from .exe. I got this message

 

NOTE: The infile
      'myfile.exe' is:
      Unnamed Pipe Access Device,

      PROCESS=myfile.exe,
      RECFM=V,LRECL=32727


NOTE: 0 records were read from the infile
      'myfile.exe'.
NOTE: The data set WORK.DOWNLOAD has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           44.61 seconds
      cpu time            0.04 seconds

Kurt_Bremser
Super User

@tekish wrote:

KurtBremser,

 

It is running with out error, but my biggest concern is how do I save the excel output from .exe. I got this message

 

NOTE: The infile
      'myfile.exe' is:
      Unnamed Pipe Access Device,

      PROCESS=myfile.exe,
      RECFM=V,LRECL=32727


NOTE: 0 records were read from the infile
      'myfile.exe'.
NOTE: The data set WORK.DOWNLOAD has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           44.61 seconds
      cpu time            0.04 seconds


Which means that myfile.exe does not produce any output that SAS can work with.

ballardw
Super User

@tekish wrote:

KurtBremser,

 

It is running with out error, but my biggest concern is how do I save the excel output from .exe. I got this message

 


If you run the program without SAS where does the output go? Perhaps you could use the SAS X command or Call System to run the program with parameters to save the output to a known named file, wait for the results (Xsync options), and then read that known output file.

 

I have to say the idea of reading spreadsheet as a data stream feels very likely to be a headache.

 

Something is to check on the actual file format it creates. Some programs lie and are actually creating something that Excel will open but are actually CSV (which SAS can usually handle pretty well) or html (which is poor for data interchange).

Tom
Super User Tom
Super User

The INPUT statement is expecting to read from the standard output generated by the command you are running in the pipe.  For example if I run the TYPE command from a CMD window It will show me the content of a text file on the screen.

 

C:\downloads>type file1.txt
"Hello World"

C:\downloads>

From your SAS log it looks like your program does NOT write anything to the standard output.  Which is good since SAS cannot very easily read a binary file like an EXCEL spreadsheet using the INPUT statement.

 

Open a command window and run that command to see what data if any it write to standard output.

 

Is it possible that your program actually worked, but instead of directing its output to the standard output it just created an actual file somewhere on your disk? If so then you could first run the command and then later read the file that it created in another step.

tekish
Quartz | Level 8

/****************************************************/

/* SAVE EXCEL FILES FROM DOWNLOAD */

/***************************************************/

%LET OUT=C:\DOWNLOAD\;

%LET REPORT=BOOK1;

FILENAME COMMANDS DDE 'EXCEL|SYSTEM';

RUN;

%LET FILE = &OUT.&REPORT..XLSX;

RUN;

DATA _NULL_;

FILE COMMANDS;

PUT "[SAVE.AS(""&FILE"")]";

PUT '[QUIT]';

RUN;

Tom
Super User Tom
Super User

How does this answer relate to the original question?

tekish
Quartz | Level 8

Tom,

 

When I run the .exe I have an excel output.

 

thanks,

Tom
Super User Tom
Super User

@tekish wrote:

Tom,

 

When I run the .exe I have an excel output.

 

thanks,


Do you mean that after running the program it leaves EXCEL running with the generated content as the currently open workbook?

tekish
Quartz | Level 8

Tom,

 

Yes.

 

 

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