This is sort of an odd question. I know that SAS has a PROC SOAP for consuming web services. I wonder if anyone has any experience consuming XML from a REST resource using SAS?
I haven't had specific experience with REST APIs from SAS, but I've worked with similar web-based services.
You can use the filename url engine to access arbitrary URLs and read the results back. YMMV as far as compatibility with particular REST APIs and XML output goes.
Alternatively, you could use system calls to programs like wget or curl to download the XML into a file, then parse the input using SAS' xml engine.
In Base SAS 9.2 there is also a new proc called proc http. It was designed specifically to call REST services (or for site scraping). You could also use the url access method for simple get requests. The advantage of proc http is that you can control the http verb used and also pass a payload.
i found this post hope be useful for u
http://blog.flair-systems.com/2010/05/how-to-consume-rest-based-services.html
Q. How to consume REST based-services?
Assume we have REST based-service contains method Add which takes two operands op1 and op2 and return the summation.
A) Create any project type (Console, Windows or even Web-based application) and add the below lines :
Code Snippet
- using System.Net;
- using System.IO;
B) Write some code to consume the service:
Code Snippet
- string parameters;
- string response;
- // Create the request obj
- WebRequest request = WebRequest.Create("serviceURL/Add");
- // Set values for the request back
- request.Method = "POST"; //REST based-services using Post method
- request.ContentType = "application/json"; //tells request the content typs is JSON
- parameters = "{\"op1\":2,\"op2\":\"1\"}";
- request.ContentLength = parameters.Length;
- // Write the request
- StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
- requestWriter.Write(parameters);
- requestWriter.Close();
- // Do the request to get the response
- StreamReader responseReader = new StreamReader(request.GetResponse().GetResponseStream());
- response = responseReader.ReadToEnd();
- responseReader.Close();
Response value should be 3 if you implement Add method correctly :))