BookmarkSubscribeRSS Feed
VAinTestMode
Calcite | Level 5

I'm getting an error trying to use the shpimprt command to load in a .SHP file.

 

I've uploaded the file I want to import into my SAS Content folder (see attached image).

 

I right-clicked on the file and selected "Insert as path" to ensure i was using the correct file path.

 

when I run my command to load the file, I see the following "file does not exist" error in the logs:

83 %shpimprt(shapefilepath=/Users/sasdemo/tl_2018_04_sldu.shp, id="GEOID", outtable=geotest, cashost=localhost,
84 casport=5570, caslib='casuser');
NOTE: PROCEDURE MAPIMPORT used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
WARNING: Physical file does not exist, /Users/sasdemo/tl_2018_04_sldu.shp.
ERROR: Unable to open DATAFILE.
 

 

3 REPLIES 3
CaseySmith
SAS Employee

It's a little confusing, but the SAS Content tree and the server file system are two separate file stores (logical and physical, respectively).  You uploaded the .shp file to the SAS Content location, but the code is referencing (looking for, but can't find) a file path on the server file system.

 

So, you have two options...

 

1) You can access a file from a SAS Content folder directly by using a FILESRVC fileref.  For example:

 

filename myfile FILESRVC folderpath="/Users/sasdemo" filename="tl_2018_04_sldu.shp";

%shpimprt(shapefilepath=myfile

 

Note: This requires that your SAS code is capable of accepting a fileref rather than only a file path string.  Since macro parameters are just strings, I doubt the shpimprt macro will accept a fileref for the sharefilepath parameter, so probably not an option for you in this example.

 

2) You can FTP the file to your server file system (or a location it can access) and then reference that file in your SAS code.

 

Note: In SAS Studio 5.1, only the SAS Content tree is surfaced in the UI.  The server file system is not accessible from the SAS Studio 5.1 UI.  In SAS Studio 5.2, the SAS Content tree and the server file system will be accessible.  Thus, you'll be able to upload directly to either.

 

Casey


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

andreas_lds
Jade | Level 19
Just an idea: is the pathname function able to return full filename to be passed to the macro?
CaseySmith
SAS Employee

I was curious, so gave it a shot, but as you'll see from this log snippet, it only returns the filename:

 

76    filename myfile FILESRVC folderpath="/Users/cassmi" filename="yo.txt";
77    %put %sysfunc(pathname(myfile));
yo.txt

Also, there isn't really a way this (getting a path that references a file from SAS Content, but can be used in a server file system context) could work, since there is no full path to this file (in server file system context). The file doesn't exist on the server file system.  It only exists in the SAS Content location.

 

Casey


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 2018 views
  • 0 likes
  • 3 in conversation