Hi,
So I came accros the ability to run commands in SAS EG, I need to do this to check for open EXCEL files, specifcally by looking for the files name. So I came across so code, which is very helpful, which I tweaked a bit.
filename tasks pipe "tasklist /v /fo table";
data process;
infile tasks;
input tasklist $500.;
if count(upcase(tasklist), "EXCEL") > 0 then output;
run;
This code runs fine, however, the data set doesnt hold the EXCEL files name, but just the EXCEL.EXE bit. Now if i run the CMD with tasklist /v /fo table, I can see the EXCEL files name, any idea why I do not see this in SAS?
any help would be great
That is weird, did you check this full line print with the posted command in a dos-box?
the N/A after unknown should be the running user on the System te last N/A should be the window name.
You did not describe your environment it is running in. Eguide to SAS-local should run under your credentials but I never checked the changes that are technical hidden from the interactive (console) usage to a batch usage (No Windows).
Wiht a spawner usage on a remote Windows SAS server it the local system account getting some role introducing more differences.
Any way, your command execution did work. The information on the Windows names is not as wanted.
https://technet.microsoft.com/en-us/library/cc730909.aspx see the remark on the remote system not having the windowtitle available.
One pitfall could be te maximum record length als of conventions often limited to 255 https://support.sas.com/documentation/cdl/en/hostwin/63285/HTML/default/viewer.htm#chfoptfmain.htm
Wiht a mode con cols=255 you can make the dos-box as wide as that. Your command will show the window name (can be set as filename). This one seems not be the problem.
The input statement seems logical understandablem but it is list input http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#n0lrz3gb7m9e4rn...
List input doesn't process lengths like column input instead it spearates by using conventions like spaces.
You instruction is to read the first blank delimited string. That is what has been executed and what you are seeing.
Using the automatic variable _infile_ you will have the complete record (length by lrecl).
Hi thanks for the response,
I changesd my code based on your suggestion
filename tasks pipe "tasklist /v /fo table";
options noxwait lrecl = 500;
data process;
infile tasks;
input tasklist $500.;
put _infile_;
if count(upcase(tasklist), "EXCEL") > 0 then output;
run;
options lrecl = 256;
And still no luck, once run the log displays the EXCEL.exe applications like so
EXCEL.EXE 4844 0 101,288 K Unknown N/A 0:04:11 N/A EXCEL.EXE 5956 0 42,072 K Unknown N/A 0:00:16 N/A
That is weird, did you check this full line print with the posted command in a dos-box?
the N/A after unknown should be the running user on the System te last N/A should be the window name.
You did not describe your environment it is running in. Eguide to SAS-local should run under your credentials but I never checked the changes that are technical hidden from the interactive (console) usage to a batch usage (No Windows).
Wiht a spawner usage on a remote Windows SAS server it the local system account getting some role introducing more differences.
Any way, your command execution did work. The information on the Windows names is not as wanted.
https://technet.microsoft.com/en-us/library/cc730909.aspx see the remark on the remote system not having the windowtitle available.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.