BookmarkSubscribeRSS Feed
shankar_kumar
Calcite | Level 5
Hi Everyone

I am using SAS Enterprise Guide in windows XP environment.

As part of my automation work, I need to pick the latest .txt file from a list of different files in a folder and then do some operations on that.

Is there any way in SAS which I can use to do this?

Request your help.

Thanks
Shankar
4 REPLIES 4
Patrick
Opal | Level 21
Hi

You basically have to issue a command to the OS to get the information you need (i.e. creation date). So first thing you're doing is to open a command window (for Windows or UNIX - whatever your server environment is ) and get the command right. You then use either "filename ... pipe" or an "X" command from within SAS to send the "OS" command and retrieve the result for further processing. There are several examples in the SAS doc and in SAS notes of how to do this.

The one thing you should check first is if you're allowed to issue OS command from an EG session. Execute "Proc Options; run;" and then look in the log for "XCMD". If the value is "NOXCMD" (that's the installation default) then you've got a problem because EG won't allow you to issue OS commands. You then would have to talk to your SAS admin first.

HTH
Patrick
shankar_kumar
Calcite | Level 5
Hi Patrick

Thanks for your reply.

However, as said I am not allowed to use any OS specific commands as they are disabled.

Any other way which I can use to do it apart from requesting SAS admin?

Please suggest.

Thanks
Shankar
Patrick
Opal | Level 21
Hi

You don't need to become a SAS admin - but your SAS admin would have to change NOXCMD to XCMD.

NOXCMD is a security feature. So there shouldn't be a way around it.

If you know the possible filenames then you could issue filename statements and then query the dictionary table. This would give you the information you're after.


filename tst1 'c:\temp\test.txt';
filename tst2 'c:\temp\test2.txt';

proc sql;
select *
from sashelp.vextfl
where fileref like 'TST%';
quit;


HTH
Patrick
TomKari
Onyx | Level 15
Hi, Shankar

Here's a (slightly modified) piece of code that I use in EG on XP. It uses the SAS "External Files" functions to find the files in a directory. I only need the filename, but there's an "FINFO" function that you can probably use to get date information.

Tom

data work.dsns(keep=infref);
length infref $ 64;
rc=filename("htmldir","c:\Source");
htmld=dopen("htmldir");
dsncount=dnum(htmld);
do i = 1 to dsncount;
infref = dread(htmld,i);
end;
rc=dclose(htmld);
run;

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!

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