BookmarkSubscribeRSS Feed
sagulolo
Quartz | Level 8

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

11 REPLIES 11
Kurt_Bremser
Super User

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.

sagulolo
Quartz | Level 8

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

Kurt_Bremser
Super User

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.

sagulolo
Quartz | Level 8

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.

Kurt_Bremser
Super User
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.

sagulolo
Quartz | Level 8

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

Kurt_Bremser
Super User

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

s_lassen
Meteorite | Level 14

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

sagulolo
Quartz | Level 8

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

sagulolo
Quartz | Level 8

Hi Reeza,

 

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

 

Best Regards

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
  • 11 replies
  • 1347 views
  • 2 likes
  • 4 in conversation