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
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.
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
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.
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.
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.
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
@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.
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.
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
Try using WildCards and the concepts here:
Hi Reeza,
thank for the sample, but my issue is unable to read from sharefolder(as describe by KurtBremser).
Best Regards
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 25. 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.