In addition to the dictionary tables, you can open the attributes of the data set in a DATA Step. If you are going to work with arrays, you may want to separate the character from the numeric variables. Here is sample code: %let indsn=sashelp.class; data _NULL_; length varnme $32 varClst varNlst $32767; dsid = open("&indsn"); /* open data set attributes */ vars = attrn(dsid,"NVARS"); /* get number of variables */ do i = 1 to vars; /* go through variable names */ varnme = varname (dsid, i); /* name of variable */ vartype = vartype(dsid,i); /* Character or numeric? */ if vartype = "C" then varClst = catx(' ',varClst,varnme); else varNlst = catx(' ',varNlst,varnme); end; cntC = count(strip(varClst),' ') + 1; cntN = count(strip(varNlst),' ') + 1; call symputx('varClst',varClst); /* put variable list in macro variable */ call symputx('varNlst',varNlst); /* put variable list in macro variable */ call symputx('varCcnt',cntC); /* put variable count in macro variable */ call symputx('varNcnt',cntN); /* put variable count in macro variable */ rc = close(dsid); /* close data set attributes */ run; %put _user_; /* verify existence of macro variables */
... View more