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

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

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jakarman
Barite | Level 11

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.  

---->-- ja karman --<-----

View solution in original post

3 REPLIES 3
jakarman
Barite | Level 11

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).

 

 

 

---->-- ja karman --<-----
craig159753
Quartz | Level 8

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                                                            

 

 

 

jakarman
Barite | Level 11

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.  

---->-- ja karman --<-----

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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