LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 28 Nov 2006 08:00:20 -0800
Reply-To:   "J. Manuel Picaza" <JMPicaza@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "J. Manuel Picaza" <JMPicaza@GMAIL.COM>
Organization:   http://groups.google.com
Subject:   Re: test for the format of a variable?
Comments:   To: sas-l@uga.edu
In-Reply-To:   <9888BE752Davidwrightspracom@207.115.17.102>
Content-Type:   text/plain; charset="us-ascii"

Hi David,

The information regarding the columns in a table can be found easily with proc sql.

Some useful tips are;

proc sql; describe table dictionary.columns; describe table dictionary.tables;

create table columns as select * from dictionary.columns where libname='YOUR_LIB' and memname='YOUR_TABLE'; quit;

with those tools is very easy to build a macro for returning the type of a varible:

%macro typeOfVar(memname=WORK,libname=DATA1,name=); proc sql noprint; select type into :type from dictionary.columns where memname=trim(upcase("&memname.")) and libname=trim(upcase("&libname.")) and name=trim(upcase("&name.")); quit; %mend typeOfVar;

or you can create dataset like:

proc sql; create table numVarsInWORK as select libname, memname, name, type, format from dictionary.tables where libname='WORK'; quit;

The code is very easy to read and the information you can get is awesome.

Regards, Manuel

David Wright wrote:

> Is there a way to check if a data set variable is numeric, without having to > write lots of confusing code? > > I have a macro which runs some datastep statements including the Substr() > function, and I want to skip everything if the data step variable is not > charater (or many convert it). > > Now I could use Fopen and attrm, but I really don't want to get into all that > because if makes the code complex and The Others upset.


Back to: Top of message | Previous page | Main SAS-L page