Hi All,
I am trying to learn how to execute an api call on sas 9.3 using an example from below document .
But am getting the below error .
when I checked online for the error , I am getting the resolution as changing the config file
C:\SAS\Lev1\SASApp\sasv9.cfg ...
is there another mothod to excute this proc http .
Thanks in advance.
https://www.lexjansen.com/mwsug/2012/S1/MWSUG-2012-S110.pdf
%macro sas_getDist; data _null_; length url $ 2048; url = catt( 'http://maps.googleapis.com/maps/api/directions/xml?origin=', &start, '&destination=', &end, '&sensor=false&alternatives=false'); url = translate(trim(url), '+', ' '); call symputx('REQUEST_URL', url); run; FILENAME dist "\\Desktop\SAS\RESPONSE1.txt"; proc http out = dist url = "%superq(REQUEST_URL)" method = "GET" ct = "application/x-www-form-urlencoded"; run; filename xml_map "\\Desktop\SAS\google-maps-dist.map"; libname dist xml xmlmap=xml_map; data _null_; set dist.distance; /* 1 mile = 1,609.344 meters */ dist = dist / 1609.344; call symputx('DIST', dist); run; %mend; proc fcmp outlib=sasuser.funcs.web; function sas_getDist(start $, end $); rc = run_macro('sas_getDist', start, end, dist); return (dist); endsub; quit; data addresses; length name $ 32 address $ 128; infile datalines truncover; input name address $128.; datalines; SAS SAS Campus Dr., Cary, NC 27513 YMCA 1603 Hillsborough St., Raleigh, NC 27605 NCSU Joyner Visitor Center, NC State University, Raleigh, NC 27695-7504 UNC-CH UNC Visitor Center, 250 East Franklin Street, Chapel Hill, NC ; options cmplib=sasuser.funcs; data distances; set addresses; dist = sas_getDist('SAS Campus Dr., Cary, NC, 27513', address); run; proc print data=addresses; where sas_getDist('SAS Campus Dr., Cary, NC, 27513', address) < 10; run;
ERROR: 59 proc fcmp outlib=sasuser.funcs.web; 60 function sas_getDist(start $, end $); 61 rc = run_macro('sas_getDist', start, end, dist); 62 return (dist); 63 endsub; 64 quit; ERROR: Write access to member SASUSER.FUNCS.DATA is denied. WARNING: Failed to save function sas_getDist to sasuser.funcs.web.
ERROR 2 -------------- WARNING: No CMP or C functions found in library sasuser.funcs. 79 dist = sas_getDist('SAS Campus Dr., Cary, NC, 27513', address); ___________ 68 ERROR 68-185: The function SAS_GETDIST is unknown, or cannot be accessed.
Use another library in PROC FCMP, and set the COMPLIB= system option accordingly.
This:
proc fcmp outlib=sasuser.funcs.web;
directs SAS to store the new function in a catalog in the SASUSER library; in your setup, this library is used in read-only mode.
Similarly, this:
options cmplib=sasuser.funcs;
tells SAS where to look for compiled functions. You need to use a different library for this; if you don't want the function to be permanently available, you can use WORK.
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 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: