BookmarkSubscribeRSS Feed
JussiV
SAS Employee

Couple of weeks ago I had a customer of mine contacting me and claiming  that her Proc Import did not work even though the File Import was working fine in her SAS Enterprise Guide. Well, the issue here was quite simply that File Import function operates on the PC and "sees" the directories, folders and files as the PC sees them. But, when you execute the Proc Import, the code is transmitted to the SAS server and excuted there.

The problem was that we had no external access to the server and we had no idea what was the name of the drive where the import file was stored. We needed a way "to see" what were the names of the directories in the SAS server. I found the following code to do that:

 

filename diskinfo PIPE "wmic logicaldisk get name, description";
data _null_;
   infile diskinfo;
   input;
   put _infile_;
run;

 

 

The trick is the PIPE option of the filename command and then process that filename in the following data _null _ statement.

The PIPE option directs the OS commands within the quotation marks to the underlying OS and the following put- statement writes the results to the SAS log- window. Works nicely in your SAS EG session.

 

The filename with the PIPE option works also with the SAS Viya environments and Linux OS-commands. That's the only way to access OS system from SAS Program editor now that X- command is not allowed in normal SAS Viya sessions.

81   filename diskinfo PIPE "pwd";
82   
83   data _null_;
84      infile diskinfo;
85      input;
86      put _infile_;
87   run;
NOTE: The infile DISKINFO is:
      Pipe command="pwd"
/opt/sas/viya/config/var/run/compsrv/default/938c560d-8b53-44a0-8796-5ddbf2beebc1
NOTE: 1 record was read from the infile DISKINFO.
      The minimum record length was 81.
      The maximum record length was 81.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Discussion stats
  • 0 replies
  • 726 views
  • 4 likes
  • 1 in conversation