By default, the script uses 'sashelp.class' via the %defaults macro. The source table can be dynamically modified via the 'dset' macro variable. A 'dtemp' library pointing to 'D:\Temp' is defined but not explicitly used in the main transformation logic.
1 Code Block
LIBNAME
Explanation : Definition of a temporary library (Windows path, to be adapted for Viya/Linux).
Copied!
libname dtemp 'D:\Temp';
1
LIBNAME dtemp 'D:\Temp';
2 Code Block
MACRO
Explanation : Initialization of default parameters (source table, start, limit) if not provided by the calling environment.
Explanation : Creation of the 'subset' table containing only the data for the requested page.
Copied!
data subset;
set &dset (firstobs=&first obs=&last);
run;
1
2
DATA subset;
3
SET &dset (firstobs=&first obs=&last);
4
RUN;
5
6 Code Block
DATA STEP
Explanation : DATA _NULL_ step that iterates through the 'subset' table and manually writes a formatted JSON structure (totalCount, rows) to the '_webout' output filestream. The code dynamically inspects variable types (numeric or character) to correctly format JSON values.
Copied!
data _null_ ;
length type $ 1 char $ 128 num 8;
file _webout;
dsid=open("subset");
/* ... logique de génération JSON ... */
dsid=close(dsid);
run;
1
DATA _null_ ;
2
LENGTH type $ 1 char $ 128 num 8;
3
file _webout;
4
dsid=open("subset");
5
/* ... logique de génération JSON ... */
6
dsid=close(dsid);
7
RUN;
7 Code Block
MACRO
Explanation : Calling standard Stored Process macros to finalize execution and manage output.
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.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.