Search notes:

SAS programming - macro function: %sysfunc

%sysfunc is a macro function that can execute most data step functions.
/* %sysfunc (and %qsysfunc) can execute most SAS functions */

%let text=foo bar baz;
%let sub_4_3=%sysfunc(substr(&text, 5, 3));
%put &sub_4_3;

%put %sysfunc(date(), worddate.);
Github repository about-SAS, path: /macro-processor/functions/sysfunc/basic.sas

No quoting

Macro variables need/must not be quoted when used as argument to a function within %sysfunc. When the same macro variable is used in a data step, it needs to be quoted:
%let var=foo bar baz;

/* &var is used in macro context: it needs not be
   quoted: */
%put length of var is %sysfunc(length(&var));

data _null_;
  /* &var is used in a data step: it must be
     must be quoted: */
  len = length("&var");
  put "length of var is " len;
run;
Github repository about-SAS, path: /macro-processor/functions/sysfunc/no-quoting.sas

putn

The following example uses %sysfunc to call putn in order to format a variable with a specific format.
putn is needed because put is not available in the macro environment.
%macro tq84_yyyymm;

  %do yyyy=2015 %to 2017;
  %do m   =   1 %to   12;

      %let mm=%sysfunc(putn(&m, z2.));

      %put &yyyy&mm;

  %end; %end;
  
%mend tq84_yyyymm;
Github repository about-SAS, path: /macro-processor/functions/sysfunc/putn.sas

See also

macro functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Companie...', 1758206519, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Companies-Products/SAS/programming/macros/functions/sysfunc/index(89): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78