Search notes:

SAS statements: array with _numeric_ and _character_

In the following two examples, two arrays are declared that refer to the numeric and character variables using the special variable lists _numeric_ and _character_.

_character_

data _null_;

   var_foo  =  42;
   var_bar  = 999;
   var_baz  =  17;
   var_chr1 ='foo';
   var_chr2 ='bar';
   var_chr3 ='baz';



/* All non-temporary character variables can be referenced
   with _character_: */
   array ary{*} _character_;

   do i=1 to dim(ary);
      put 'ary ' i ': ' ary[i];
   end;
/* The put statement puts:
       ary 1 : foo
       ary 2 : bar
       ary 3 : baz
*/

run;
Github repository about-SAS, path: /programming/statements/array/_character_.sas

_numeric_

data _null_;

   var_foo  =  42;
   var_bar  = 999;
   var_baz  =  17;
   var_char ='foo bar baz';

/* All non-temporary numeric variables can be referenced
   with _numeric_: */
   array ary{*} _numeric_;

   do i=1 to dim(ary);
      put 'ary ' i ': ' ary[i];
   end;
/* The put statement puts:
     ary 1 : 42
     ary 2 : 999
     ary 3 : 17
*/

run;
Github repository about-SAS, path: /programming/statements/array/_numeric_.sas

Index