![]() Chapter Contents |
![]() Previous |
![]() Next |
| VARTYPE |
| Category: | SAS File I/O |
| Syntax | |
| Arguments | |
| Details | |
| Examples | |
| See Also |
Syntax |
| VARTYPE(data-set-id,var-num) |
| Tip: | This number is next to the variable in the list that is produced by the CONTENTS procedure. |
| Tip: | The VARNUM function returns this number. |
| Details |
VARTYPE returns C for a character variable or N for a numeric variable.
| Examples |
%let dsid=%sysfunc(open(mydata,i));
%let varlist=;
%do i=1 %to %sysfunc(attrn(&dsid,nvars));
%if (%sysfunc(vartype(&dsid,&i)) = N) %then
%let varlist=&varlist %sysfunc(varname
(&dsid,&i));
%end;
%let rc=%sysfunc(close(&dsid));
data vars;
length name $ 8 content $ 20;
drop dsid i num fmt rc;
dsid=open("mydata","i");
num=attrn(dsid,"nvars");
do while (fetch(dsid)=0);
do i=1 to num;
name=varname(dsid,i);
fmt=varfmt(dsid,i);
if (vartype(dsid,i)='C') then do;
content=getvarc(dsid,i);
if (fmt ne '' ) then
content=left(putc(content,fmt));
output;
end;
end;
end;
rc=close(dsid);
run;
| See Also |
| Function:
|
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.