Published on :

DBPedia Query via SAS-SPARQLwrapper

This code is also available in: Deutsch Français
Awaiting validation
This program performs a simple SPARQL query on the public DBPedia endpoint to retrieve the label and abstract of the 'SPARQL' resource. It filters the results to keep only texts in English or without a specified language. The result is stored in a SAS© table and then displayed.
Data Analysis

Type : EXTERNE


Data comes from a web service call (DBPedia SPARQL Endpoint) via the %sparqlquery macro.

1 Code Block
OPTIONS
Explanation :
Configuration of log options and inclusion of the external macro file 'sparqlquery.sas' required for execution.
Copied!
1options mprint mlogic nocenter;
2%include "sparqlquery.sas";
3 
2 Code Block
MACRO CALL Data
Explanation :
Call to the %sparqlquery macro to send the SELECT query to the DBPedia endpoint. The result is stored in the 'query' table. Uses an external XML map file.
Copied!
1%sparqlquery(
2endpoint=http://dbpedia.org/sparql,
3query=%str(
4PREFIX rdfs: 2000/01/rdf-schema#>
5SELECT ?label ?abstract
6WHERE { rdfs:label ?label;
7 ?abstract.
8 FILTER (lang(?abstract) = "" || lang(?abstract) = "en")
9 }
10),
11querymethod=queryGET,
12resultdsn=query,
13sparqlquerysxlemap=%str(sparqlquery-sxlemap.map),
14debug=Y
15);
3 Code Block
PROC PRINT
Explanation :
Display of the content of the resulting 'query' table in the output.
Copied!
1PROC PRINT DATA=query width=min;
2RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.