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.

>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(OBJ,class,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, options are: PROCJSON (default) DATASTEP
dbg=DEPRECATED - was used to conditionally add PRETTY to proc json but this can cause line truncation in large files.
Version
9.2
Author
Allan Bowe @source https://github.com/sasjs/core

Definition in file mp_jsonout.sas.