*
; /* Re: Checking for Numeric or Character Variable Types Date: 1996/02/22 author: Christopher Zogby e-mail: chris@PHOR.COM sender: SAS(r) Discussion";organization: Pharmaceutical Outcomes Research, Inc. comments: To: drh4@PSU.EDU reply-to: Christopher Zogby Daryl R Hoffman asks about Checking for Numeric or Character Variable Types. The macro below write the data set name followed by the variable names and their type (char or num) to the log and to the data set VARTYPE. Hope this helps. regards, Chris +*******************************************+ | Christopher Zogby | | SAS Programmer/Analyst | | Pharmaceutical Outcomes Research, Inc. | | 435 Lawrence Bell Drive | | Williamsville, NY 14221 | | Phone: (716) 633-3463 | | Fax: (716) 633-7404 | | e-mail: chris@phor.com | +*******************************************+ */ options nosource; %macro vartype(dsn); options nomprint nosymbolgen nonotes; /*if user supplies two level name*/ %if %scan(&dsn,2,.) ne %then %do; /*extracts out libname*/ %let libname=%upcase(%substr(&dsn,1,%eval(%index(&dsn,.)-1))); /*extracts out data set name*/ %let dsn=%upcase(%substr(&dsn,%eval(%index(&dsn,.)+1))); %end; /*user supplies only data set name*/ %else %do; %let libname=WORK; %let dsn=%upcase(&dsn); %end; proc sql; create table vartype as select name, type from dictionary.columns where libname="&libname" and memname="&dsn"; /*writes output to the log*/ data _null_; if _n_=1 then put 'Data check includes variables from ' "&libname"'.'"&dsn"'.'; set vartype; put 'Variable ' name ' is ' type '.'; run; options notes; %mend vartype; options source; *Example; data one; input x y id $; cards; 1 2 z 2 3 b run; %vartype(work.one); proc print data=vartype; run; *