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 secondscpu time 0.01 secondsWARNING: Physical file does not exist, /Users/sasdemo/tl_2018_04_sldu.shp.ERROR: Unable to open DATAFILE.
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
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
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!
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.