INIT:
   dsid=open('sasuser.houses');

   vars=makelist();
   poss=makelist();
   fmts=makelist();

   nvar=attrn(dsid, 'nvars');
   pos=1;

   do i=1 to nvar;
      varname=varname(dsid, i);
      vartype=vartype(dsid, i);
      varlen=varlen(dsid, i);
      varfmt=varfmt(dsid, i);

      wid=0;
      start=indexc(varfmt,'0123456789');
      end=index(varfmt,'.');
      if(start & end) then
         wid=input( substr(varfmt,start,end-start),3.);
      if wid=0 then
         wid=max( length(varname), varlen );
      if wid=0 | wid=. then
         wid=8;

      if (vartype='C') then
         vartype='CHAR';
      else
         vartype='NUM';

      rc=setnitemc(vars, vartype, varname);
      rc=setnitemc(fmts, varfmt, varname);
      rc=setitemn(poss, pos, i, 'y');

      substr(temphead, pos) = varname;
      pos=pos+wid+1;

      end;

      call notify('table', '_set_maxcol_', pos);

return;

GET1:

      if (fetchobs(dsid, _currow_)) then
         call notify('table', '_endtable_');

      else do;
         do i = 1 to nvar;
            vartype=getitemc(vars, i);
            varname=nameitem(vars, i);
            pos=getitemn(poss, i);
            varfmt=getitemc(fmts, i);

            if (vartype='CHAR') then do;
               valuec=getvarc(dsid, i);
               if varfmt^='' then do;
                  valuec=putc(valuec, varfmt);
               end;

               substr(tempvar, pos)=valuec;
            end;

            else /* vartype='NUM' */ do;
               valuen=getvarn(dsid, i);
               if varfmt^='' then do;
                  valuec=putn(valuen,varfmt);
                  substr(tempvar, pos)=valuec;
               end;

               else substr(tempvar, pos)=valuen;

            end;

         end;

         varline=substr(tempvar , _curcol_);

         if _status_='G' then
            headline=substr(temphead , _curcol_);

      end;

return;

TERM:

      call close(dsid);

return;