Published on :
Reporting INTERNAL_CREATION

Call for Report Generation

This code is also available in: Deutsch Español Français
Awaiting validation
The `call_create_report` macro is designed to be invoked from a shell script. It retrieves a character string via the `SYSPARM` system variable, which it parses to extract an `id_report_control` and a `rundate`. Then, it calculates a `datestamp` (current date) and a `timestamp` (current minute's time) using SAS© functions. Finally, it transfers all these parameters to a `create_report` macro (whose code is not included here) which is responsible for the actual report creation logic. Global SAS© options are defined to improve debugging and macro variable management.
Data Analysis

Type : INTERNAL_CREATION


The data used consists mainly of input parameters (`SYSPARM`) processed into macro variables, and date/time variables dynamically generated by SAS (`DATE()`, `DATETIME()`). There is no explicit reading of data from SASHELP tables or external sources in this code fragment, with the exception of what might be handled by the `create_report` macro, which is not provided.

1 Code Block
MACRO
Explanation :
Defines the beginning of the `call_create_report` macro and initializes the `SYSPARM` macro variable with the value passed to SAS via the command line, then displays it in the log.
Copied!
1%macro call_create_report();
2%let SYSPARM=&SYSPARM ;
3%put SYSPARM=&SYSPARM;
4 
2 Code Block
DATA STEP Data
Explanation :
This `DATA _NULL_` block is used to extract values from the `SYSPARM` macro variable. The `SCAN` function allows elements to be separated by commas, and `CALL SYMPUT` assigns them to new macro variables (`id_report_control` and `rundate`).
Copied!
1 DATA _null_ ;
2 call symput('id_report_control',trim(left(scan("&SYSPARM",1,',')))) ;
3 call symput('rundate',trim(left(scan("&SYSPARM",2,',')))) ;
4 RUN ;
3 Code Block
MACRO Data
Explanation :
This block uses `%SYSFUNC` macro functions to manipulate and format dates and times. `rundate` is converted to SAS date format, `datestamp` obtains the system date in YYMMDD format, and `timestamp` extracts the time from the system timestamp in HH0000 format. A `zip_counter` variable is initialized to 0.
Copied!
1 /* rundate is the date variable of the extraction*/
2 %let rundate = %SYSFUNC(INPUTN(&rundate,yymmdd8.));
3 %put rundate=%sysfunc(putn(&rundate,yymmdd10.));
4
5 /*datestamp is the wariable for the ZIP file*/
6 %let datestamp = %sysfunc(DATE(),yymmdd6.);
7 %put datestamp=&datestamp.;
8 %let zip_counter = 0;
9 /*timestamp is the wariable for the ZIP file*/
10 %let timestamp = %sysfunc(substr(%sysfunc(DATETIME(),datetime19.),11,2))0000;
11 %put timestamp=×tamp.;
4 Code Block
MACRO
Explanation :
Displays the final values of the `id_report_control` and `datestamp` macro variables in the log. Then, it calls the `create_report` macro (not defined in this code), passing all prepared macro variables as parameters. `ABSOLUTE` is a typo and is not valid. Finally, it ends the definition of the `call_create_report` macro.
Copied!
1
2 %put id_report_control = &id_report_control. ;
3 %put datestamp = &datestamp. ;
4 %create_report(&id_report_control.,&datestamp.,×tamp.,&rundate.);
5%mend call_create_report;
5 Code Block
OPTIONS / EXECUTION
Explanation :
Sets global SAS options: `MPRINT` to display code lines generated by macros, `MVARSIZE=MAX` to allow large macro variables, and `NOQUOTELENMAX` to disable truncation of quoted strings. Finally, it executes the `call_create_report` macro.
Copied!
1options mprint;
2options MVARSIZE=MAX;
3options noquotelenmax;
4%call_create_report();
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.
Copyright Info : ykxjlau 27.02.2013: Created.