LUA enables most existing SAS functions to be re-used. The following code opens a dataset (getting a temporary handle identifier), queries the metadata (number of logical / non deleted observations) and finally closes the handle.

proc lua;
submit;
  local dsid=sas.open('sashelp.class')
  local obs=sas.get_attr(dsid,'NLOBS')
  local rc=sas.close(dsid)
  print(obs)
endsubmit;
run;

NOTE - the above will only work on SAS datasets, not on third party databases!