Production Ready Macros for SAS Application Developers
https://github.com/sasjs/core
mp_jsonout.sas File Reference

Writes JSON in SASjs format to a fileref. More...

Go to the source code of this file.

Detailed Description

PROC JSON is faster but will produce errs like the ones below if special chars are encountered.

(ERR)OR: Some code points did not transcode.

An object or array close is not valid at this point in the JSON text.

Date value out of range

If this happens, try running with ENGINE=DATASTEP.

Usage:

  filename tmp temp;
  data class; set sashelp.class;run;

  %mp_jsonout(OPEN,jref=tmp)
  %mp_jsonout(OBJ,class,jref=tmp)
  %mp_jsonout(CLOSE,jref=tmp)

  data _null_;
  infile tmp;
  input;list;
  run;

If you are building web apps with SAS then you are strongly encouraged to use the mX_createwebservice macros in combination with the sasjs adapter. For more information see https://sasjs.io

Parameters
actionValid values:
  • OPEN - opens the JSON
  • OBJ - sends a table with each row as an object
  • ARR - sends a table with each row in an array
  • CLOSE - closes the JSON
dsthe dataset to send. Must be a work table.
jref=the fileref to which to send the JSON
dslabel=the name to give the table in the exported JSON
fmt=Whether to keep or strip formats from the table
engine=Which engine to use to send the JSON, valid options are:
  • PROCJSON (default)
  • DATASTEP (more reliable when data has non standard characters)
dbg=DEPRECATED - was used to conditionally add PRETTY to proc json but this can cause line truncation in large files.

Related Macros @li mp_ds2fmtds.sas @version 9.2 @author Allan Bowe @source https://github.com/sasjs/core

Definition in file mp_jsonout.sas.