LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (November 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 18 Nov 2002 13:01:08 -0500
Reply-To:   "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM>
Subject:   Re: Is a variable Numeric?
Content-Type:   text/plain; charset="iso-8859-1"

Or, if a boundary-less solution is required, use macro:

%macro typevar (data=, var=);

%local dsid ; %let dsid = %sysfunc(open (&data)); %if &dsid %then %do; %let varnum = %sysfunc (varnum (&dsid, &var)); %if &varnum %then %do; %sysfunc (vartype(&dsid, &varnum)); %end; %else %do; Invalid variable %end; %let dsid = %sysfunc(close(&dsid)); %end; %else %do; Invalid dataset %end;

%mend;

%put %typevar(data=scores,var=score_desc)

Returns C, N or one of the "Invalid .." messages.

-----Original Message----- From: Marianne Whitlock [mailto:WHITLOM1@WESTAT.COM] Sent: Monday, November 18, 2002 12:19 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Is a variable Numeric?

Regarding your first question "How do I check if a variable is numeric?", I assumed you meant in a SAS file. I imagined your having a macro which handles many datasets, and many variables, and your program needs to know whether a particular variable (&VARNAME) in a particular dataset (&DSNAME) is numeric or character. You could get the answer into a macro variable, and then make use of the result in a subsequent step:

proc sql noprint; select upcase(TYPE) into: CHARNUM from dictionary.columns where LIBNAME="AAA" and upcase(MEMNAME)=upcase("&DSNAME") and upcase(NAME)=upcase("&VARNAME") ; quit; %put CHARNUM=&CHARNUM;

-----Original Message----- From: GADI_B@MALAM.COM [mailto:GADI_B@MALAM.COM] Sent: Monday, November 18, 2002 3:53 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Is a variable Numeric?

Hi all,

How do I check if a variable is numeric?

How do I check if a text variable has numeric content (only digits, a period and a sign)?

TIA

Gadi


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