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 (September 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 14 Sep 2007 11:08:36 -0500
Reply-To:     "data _null_," <datanull@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "data _null_," <datanull@GMAIL.COM>
Subject:      Re: Test if a variable is in PDV ?
Comments: To: "Richard A. DeVenezia" <rdevenezia@wildblue.net>
In-Reply-To:  <msxGi.24$Ux4.18451@news.sisna.com>
Content-Type: text/plain; charset=ISO-8859-1

On 9/14/07, Richard A. DeVenezia <rdevenezia@wildblue.net> wrote: > varname is a character variable whose value should be the name of a > variable in the PDV. > > VNAMEX() can tell me if a variable exists during a data step, however it > writes (what I consider) extraneous NOTE:s in the log. > Is there a way to test without seeing a NOTE: when the variable being tested > for does not exist?

You could call on VNEXT to load a look up table. data _null_; declare hash v();

/* abc = 'something';*/ def = 1; varname = 'x';

link vnext;

if v.check(key:varname) eq 0 then do; name = vnamex(varname); put name= varname=; select (vtypex (varname)); when ('C') varname_cvalue = vvaluex(varname); when ('N') varname_nvalue = inputn(vvaluex(varname),vinformatx(varname)); otherwise put varname= 'not a base type'; end; put 'NOTE: IN PDV ' (_all_)(=); end; else put 'NOTE: NOT IN PDV ' (_all_)(=); return;

vnext: length _v_ $32 _t_ $8 _l_ 8 _j_ 8; v.defineKey('_v_'); v.defineData('_j_','_v_','_t_','_l_'); v.defineDone();

do _j_ = 1 by 1; call vnext(_v_,_t_,_l_); if _v_ eq '_v_' then leave; v.add(); put 'INFO: ' (_j_ _v_ _t_ _l_)(=); end; /* v.output(dataset:'Work.vars'); */ return; run;

> In the long run, it would be nice to see two new functions... > VVALUEXN > VVALUEXC > > -- > Richard A. DeVenezia >


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