ISNULL Function

Determines whether a pointer element of a structure is null.
Category: C Helper

Syntax

numeric-variable = ISNULL(pointer-element);

Required Arguments

numeric-variable
specifies a numeric value.
pointer-element
specifies a variable that contains the address of another variable.

Examples

Example 1: Generating a Linked List

In the following example, the LINKLIST structure and GET_LIST function are defined by using PROC PROTO. The GET_LIST function is an external C routine that generates a linked list with as many elements as requested.
struct linklist{
   double value;
   struct linklist * next;
};

struct linklist * get_list(int);

Example 2: Using the ISNULL C Helper Function in a Loop

The following code segment shows that the ISNULL C helper function loops over the linked list that is created by GET_LIST and writes out the elements.
proc proto package=sasuser.mylib.str2;
struct linklist{
   double value;
   struct linklist * next;
};

struct linklist * get_list(int);

externc get_list;
   struct linklist * get_list(int len){
      int i;
      struct linklist * list=0;
      list=(struct linklist*)
         malloc(len*sizeof(struct linklist));
      for (i=0;i<len-1;i++){
         list[i].value=i;
         list[i].next=&list[i+1];
      }
      list[i].value=i;
      list[i].next=0;
      return list;
   }
externcend;
run;

options pageno=1 nodate ls=80 ps=64;
proc fcmp libname=sasuser.mylib;
   struct linklist list;
   list=get_list(3);
   put list.value=;

   do while (^isnull(list.next));
      list = list.next;
      put list.value=;
   end;
run;
Results from Using the ISNULL C Helper Function
                                 The SAS System                                1

                               The FCMP Procedure

list.value=0
list.value=1
list.value=2