Published on :
ETL SASHELP

JSON Generation of a SAS Table

This code is also available in: Deutsch English Español Français
The code uses PROC JSON to export data from the built-in SASHELP.ORSALES table. The output is formatted 'pretty' (readable) and without SAS© tags. The JSON is structured as an object containing a 'rows' key whose value is an array of the exported data.
Data Analysis

Type : SASHELP


The data comes from the SASHELP library, specifically from the ORSALES table, which is an example dataset provided with SAS.

1 Code Block
PROC JSON
Explanation :
This block uses PROC JSON to generate a JSON representation of the SASHELP.ORSALES table. The OUT=_webout option directs the output to a fileref named _webout (often used in web environments to return results). The PRETTY and NOSASTAGS options improve JSON readability and compatibility. The WRITE OPEN/CLOSE OBJECT/ARRAY and WRITE VALUES statements structure the JSON, and the EXPORT statement performs data extraction.
Copied!
1* create a JSON version of the SAS table ;
2PROC JSON out=_webout pretty nosastags ;
3write open object ;
4write values "rows" ;
5write open array ;
6export sashelp.orsales ;
7write close ;
8write close ;
9RUN ;
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.