BookmarkSubscribeRSS Feed
jaiganesh
Obsidian | Level 7

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.

 

6 REPLIES 6
ballardw
Super User

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.

jaiganesh
Obsidian | Level 7

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.

JosvanderVelden
SAS Super FREQ
Do you know how to create a share for C:\files (ex: \\mypc\files) so that you can use it in the sas session that runs on the linux server?
jaiganesh
Obsidian | Level 7

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.

Tom
Super User Tom
Super User

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
jaiganesh
Obsidian | Level 7

I ran 

%put &=sysscp;

 

I got the log with 

 

SYSSCP=LIN X64

 

Now how i can i change it to the Windows ?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 6 replies
  • 1028 views
  • 0 likes
  • 4 in conversation