SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 45594: Generating a QR Code using PROC HTTP

DetailsCodeAboutRate It

Overview

PROC HTTP enables you to request and receive information from a web service.

This sample uses PROC HTTP to generate a Quick Response (QR) code from any text input. A QR code is a type of two dimensional barcode representing information such as geographical coordinates, contact information or a URL. A QR code can be read by a mobile phone or another QR-code-enabled device.

Details

Base SAS® offers two procedures for accessing web services: PROC HTTP and PROC SOAP. Use PROC HTTP for RESTful web services. For SOAP-based web services, use PROC SOAP. Both procedures are available beginning in SAS 9.2.

To call a web service with PROC HTTP, you specify options that include a fileref for the input data, a fileref for the output and a URL address for the request.

This sample shows a SAS macro that invokes PROC HTTP to call a web service for generating QR codes. The macro has two parameters: a fileref for the input and a fileref for the output which is a PNG file.

The first data step in the macro reads the input fileref and generates a string of attributes required by the web service. The attribute string is saved as a character variable in a temporary dataset. The variable's length is stored in a macro variable called "qrtextl".

The second data step writes this dataset to a text file. Taking this text file as input, PROC HTTP calls the web service. The macro variable "out" names the fileref where the output is written.

Additional Documentation

For more information on PROC HTTP, see the Base SAS 9.2 Procedures Guide


These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.