DATA Step, Macro, Functions and more

infile multiple file by common file with date and no file extension

Reply
Contributor
Posts: 60

infile multiple file by common file with date and no file extension

Dear All,

 

Need advice from your all, I have a raw file from sharefolder with a common name and follow by date(yymmdd), the file have no extension something like below:-

 

name_171030

 

have a difficulty to import a range of file into SAS Dataset. How do i import file range from name_171001 till name_171031?

How to infile common file like [name1_171001 till name1_171031] and [name2_171001 till name2_171031]?

I have code infile as per below:-

 

infile 'dir \\sharefolder\* /s /b' pipe truncover;

 

try below but not success

infile 'dir \\sharefolder\name_1710* /s /b' pipe truncover;    ***no record was retrieved

infile 'dir \\sharefolder\name_1710*.* /s /b' pipe truncover;   ***no record was retrieved

 

Thank you in advance

Super User
Posts: 10,214

Re: infile multiple file by common file with date and no file extension

Does the same directory listing provide a result when run from the commandline?

Also try the following:

filename oscmd pipe "dir \\sharefolder\name_1710* /s /b 2>&1";

data _null_;
infile oscmd;
input;
put _infile_;
run;

to see if you get any result from the command in the SAS log.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 60

Re: infile multiple file by common file with date and no file extension

Posted in reply to KurtBremser

Hi KurtBremser,

 

no record was retrieved.

Checked the log and I get below:-

 

NOTE: The infile OSCMD is:
Unnamed Pipe Access Device,
PROCESS=dir \\sharefolder\name_1710* /s /b 2>&1,
RECFM=V,LRECL=32767

NOTE: 1 record was read from the infile OSCMD.
The minimum record length was 17.
The maximum record length was 17.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.MULTIPLE_CMC_FITAS has 0 observations and 33 variables.
NOTE: DATA statement used (Total process time):
real time 0.21 seconds
cpu time 0.03 seconds

 

Best Regards

Super User
Posts: 10,214

Re: infile multiple file by common file with date and no file extension

You obvioulsy did not run my code as posted. My code does NOT produce a dataset, but it writes everything that it receives from the external command to the log. Please RUN MY CODE AS POSTED, and look at the log. Since 1 record was read from the infile, I guess it's the error message that we're looking for.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 60

Re: infile multiple file by common file with date and no file extension

Posted in reply to KurtBremser

Hi KurtBremser,

 

Apologize as i posted my version log to you.

FYI, dir address was amended.

 

Please refer below:-

NOTE: The infile OSCMD is:
Unnamed Pipe Access Device,
PROCESS=dir \\sharefolder\NAME_1710* /s /b 2>&1,
RECFM=V,LRECL=32767

Access is denied.
NOTE: 1 record was read from the infile OSCMD.
The minimum record length was 17.
The maximum record length was 17.
NOTE: DATA statement used (Total process time):
real time 0.33 seconds
cpu time 0.01 seconds

 

Please advice.

Super User
Posts: 10,214

Re: infile multiple file by common file with date and no file extension

Access is denied.

This is what we were aiming for. In the context of your SAS session, you do not have access to the resource in question. Since you seem to be on a Windows server, this might have to be fixed on the IWA side.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 60

Re: infile multiple file by common file with date and no file extension

Posted in reply to KurtBremser

Hi KurtBremser,

 

Just clarification, IWA means Integrated Windows Authentication? Means i need to refer to folder owner?

Actually I'm able to access the share folder, but SAS session is not necessary able to access, right?

 

Best Regards

Super User
Posts: 10,214

Re: infile multiple file by common file with date and no file extension


sagulolo wrote:

Hi KurtBremser,

 

Just clarification, IWA means Integrated Windows Authentication?


Yes.



Actually I'm able to access the share folder, but SAS session is not necessary able to access, right?

 


Yes, Windows can be tricky on how permissions are propagated over different environments (client/server, batch/interactive) for a given user.

A SAS workspace server runs as "batch", while a cmd window is "interactive".

 

If IWA is actually the culprit needs to be determined, but it often was the reason when similar questions were posted here.

Disclaimer: I'm a UNIX expert, so I'm not versed at all in the intricacies of Windows authorization/permissions.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
PROC Star
Posts: 260

Re: infile multiple file by common file with date and no file extension

@sagulolo:

I am not sure that you need to use an operating system command to get the file names. Just use wildcards in a file name:

data want;
  infile '\\sharefolder\name_1710??.';
input....

If you need to know which data came from which file, you can use the FILENAME= option on your infile statement.

Contributor
Posts: 60

Re: infile multiple file by common file with date and no file extension

Hi s_lassen,

 

tried the code and no record was retrieved.

checked the log and saw message below:-

 

Stderr output:
Access is denied.

 

Best Regards

Super User
Posts: 23,683

Re: infile multiple file by common file with date and no file extension

Contributor
Posts: 60

Re: infile multiple file by common file with date and no file extension

Hi Reeza,

 

thank for the sample, but my issue is unable to read from sharefolder(as describe by KurtBremser).

 

Best Regards

Ask a Question
Discussion stats
  • 11 replies
  • 194 views
  • 2 likes
  • 4 in conversation