Hello,
I've been using below code to get the list of files from LINUX environment.
Filename filelist pipe "dir /mydata/user/*.xlsx";
Data _null_;
Infile filelist truncover;
Input filename $100.;
Put filename=;
Run;
As SAS is installed in Linux, above code is working fine, However i couldn't able to use above code for Windows.
Windows directory C:\files\*.xlsx instead /mydata/user/*.xlsx, Couldn't able to recognize by SAS, As it is installed on Linux.
Please suggest how i can allocate the windows directory in FILENAME syntax so list of the files can be seen.
Any other approach to achieve list of files from windows directory is also appreciated.
Are you using the SAS University Edition where the Linux is in the virtual machine? If so then the virtual machine only sees the directories set up for it. To use any folder or files they would have to be subordinate to the location that corresponds to that location.
Otherwise I don't have a clue about running Linux on a windows machine.
It might help to show the log of what you have attempted so far. Copy the code and any messages from the log and paste into a code box opened on the forum with the {I} icon.
it generate the dataset with below result.
dir: cannot access C\:\\Users\\rong\\*: No such file or directory
dir: cannot access /s: No such file or directory
It means SAS couldn't able to read the directory from Windows as it is by default referring the Linux.
I would be appreciate if anyone can suggest the way to connect to Windows.
I've already created the shared drive, That can be accessed with right permission. Now the challenge is how i can access it through SAS.
As SAS can be easily locate linux, It should support for the Windows as well.
Does the DIR command really work on your LINUX system? Normal Unix command to list filenames is ls, not dir. But some users have made an alias to map dir to ls and some newer versions of Unix include an actual dir command.
The command to list filenames on Windows is DIR so your command should work. But only if your SAS session is actually running on Windows. To see what operating system your SAS session is using look at the automatic macro variable SYSSCP.
Window:
2 %put &=sysscp; SYSSCP=WIN
Linux:
2 %put &=sysscp; SYSSCP=LIN X64
I ran
%put &=sysscp;
I got the log with
SYSSCP=LIN X64
Now how i can i change it to the Windows ?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.