Type : MIXTE
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 | LIBNAME dtemp 'D:\Temp'; |
| 1 | %macro defaults ; |
| 2 | %IF %symexist(dset)=0 %THEN %DO; |
| 3 | %global dset; |
| 4 | %let dset=sashelp.class; |
| 5 | %END; |
| 6 | %IF ^%symexist(start) %THEN %DO; %global start; %let start=0; %END; |
| 7 | %IF ^%symexist(limit) %THEN %DO; %global limit; %let limit=160; %END; |
| 8 | %mend defaults; |
| 9 | %defaults |
| 1 | DATA _null_ ; |
| 2 | dsid=open("&dset"); |
| 3 | nobs=attrn(dsid,'nobs'); |
| 4 | call symput('nobs',strip(put(nobs,8.))); |
| 5 | RUN; |
| 1 | %let first=%eval(&start+1); |
| 2 | %let last=%eval(&start+&limit); |
| 3 | %put first=&first last=&last nobs=&nobs; |
| 4 |
| 1 | |
| 2 | DATA subset; |
| 3 | SET &dset (firstobs=&first obs=&last); |
| 4 | RUN; |
| 5 |
| 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; |
| 1 | %let _result=streamfragment ; |
| 2 | %STPBEGIN; |
| 3 | /* ... */ |
| 4 | %STPEND; |