Returns the format that is assigned to a SAS data set variable.
Category: | SAS File I/O |
specifies the data set identifier that the OPEN function returns.
specifies the number of the variable's position in the SAS data set.
Tips | This number is next to the variable in the list that is produced by the CONTENTS procedure. |
The VARNUM function returns this number. |
data vars; length name $ 8 content $ 12; drop dsid i num rc fmt; dsid=open("mydata","i"); num=attrn(dsid,"nvars"); do while (fetch(dsid)=0); do i=1 to num; name=varname(dsid,i); if (vartype(dsid,i)='N') then do; fmt=varfmt(dsid,i); if fmt='' then fmt="BEST12."; content=putc(putn(getvarn (dsid,i),fmt),"$char12."); output; end; end; end; rc=close(dsid); run;