Date: Tue, 6 Apr 2010 10:55:52 -0500
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: vvaluex error handling
In-Reply-To: <l2xf3fb762d1004060834o93b205b4h59be961d9e70d1a@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
How about just assign _ERROR_=0; in the data step. That should quite
the log. Also there is system OPTION ERRORS that controls what's
written to the log.
As far as I know there is no VEXISTX for variables that could return
0/1 if the variable exists in the PDV "at run time".
The VNEXT option shouldn't be inefficient because you don't use it but
one time to build a list of good var names. Something like this.
data test(drop=_:);
if _n_ eq 1 then do;
length _names_ $32767 _name_ $32;
do while(1);
call vnext(_name_);
if missing(_name_) then leave;
if index(_name_,'_Flag_') then _names_ = catx(' ',_names_,_name_);
end;
end;
infile cards eof=eof;
do while(1);
input (MembsEnr_Eff_Flag_200912 MembsEnr_Eff_Flag_201001
Membs_Enroll_yrmo) (2*:$1. :yymmn.);
format Membs_Enroll_yrmo yymmn.;
_name_ = cats('MembsEnr_Eff_Flag_',vvalue(Membs_Enroll_yrmo));
length V $1;
if indexW(_names_,_name_)
then v = vvalueX(_name_);
else v = ' ';
output;
end;
eof:
stop;
cards;
Y N 200912
Y Y 201001
N N 201004
;;;;
run;
proc print;
run;
On 4/6/10, Sterling Paramore <gnilrets@gmail.com> wrote:
> Yeah, but I imagine that the coding overhead for CALL VNEXT or some other
> datastep tracking algorithm would be about the same as doing it all with
> dictionary tables and macro logic, which could potentially be much faster.
> I was hoping for a simple IF/THEN statement.
>
> Thanks,
> Sterling
>
> On Tue, Apr 6, 2010 at 8:01 AM, Mike Rhoads <RHOADSM1@westat.com> wrote:
>
> > As an alternative to the OPEN function, you could use the CALL VNEXT
> > routine to iterate through the DATA step program data vector and build the
> > list of relevant variables.
> >
> >
> > Mike Rhoads
> > RhoadsM1@Westat.com
> >
> >
> > -----Original Message-----
> > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Scott
> > Barry
> > Sent: Monday, April 05, 2010 9:21 PM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: Re: vvaluex error handling
> >
> > On Mon, 5 Apr 2010 21:17:26 -0400, Scott Barry <sbarry@SBBWORKS.COM>
> > wrote:
> >
> > >On Mon, 5 Apr 2010 18:01:24 -0700, Sterling Paramore <gnilrets@GMAIL.COM>
> > wrote:
> > >
> > >>Thanks, I've never used the "open" command before. Do you know what kind
> > of
> > >>performance hits there could be if it's executed each step?
> > >>
> > >>-Sterling
> > >>
> > >>On Mon, Apr 5, 2010 at 5:48 PM, Scott Barry <sbarry@sbbworks.com> wrote:
> > >>
> > >>> On Mon, 5 Apr 2010 15:32:19 -0700, Sterling Paramore <
> > gnilrets@GMAIL.COM>
> > >>> wrote:
> > >>>
> > >>> >Dear SAS-L,
> > >>> >
> > >>> >I have some data with variable names like MembsEnr_Eff_Flag_200912,
> > >>> >MembsEnr_Eff_Flag_201001, etc. (MembsEnr_Eff_Flag_YYYYMM). These
> > fields
> > >>> are
> > >>> >either "Y" or "N". I also have another variable called
> > >>> 'Membs_Enroll_yrmo,'
> > >>> >but not all yearmonth values have a corresponding
> > MembsEnr_Eff_Flag_YYYYMM
> > >>> >field. I want to return rows where the flag field is "Y" and YYYYMM =
> > >>> >'Membs_Enroll_yrmo'. I thought I'd use the vvaluex function (one I
> > read
> > >>> >about on this list, go SAS-L!),
> > >>> >
> > >>> >data EnrEff;
> > >>> > set Enr (obs = 10);
> > >>> > if vvaluex(cats("MembsEnr_Eff_Flag_",Membs_Enroll_yrmo)) = "Y"
> > then
> > >>> >output;
> > >>> >run;
> > >>> >
> > >>> >This seems to work, but for every row where the variable does not
> > exist, I
> > >>> >get the following error message:
> > >>> >
> > >>> >NOTE: Argument to function VVALUEX is not a known variable name:
> > >>> >MembsEnr_Eff_Flag_200812.
> > >>> >NOTE: Invalid argument to function VVALUEX at line 18 column 8.
> > >>> >
> > >>> >
> > >>> >The dataset is 90 million rows, so the log quickly grows too large to
> > >>> handle
> > >>> >with this output. Is there any way to suppress the note in the log or
> > do
> > >>> >better error handling? I was hoping for something like:
> > >>> >
> > >>> > if vvalue_exist(...) then ....
> > >>> >
> > >>> >
> > >>> >
> > >>> >
> > >>> >Thanks,
> > >>> >Sterling
> > >>>
> > >>> Suggested Google advanced search argument:
> > >>> variable exist sas member site:sas.com
> > >>>
> > >>> Results (one of several) yielded:
> > >>>
> > >>> Sample 26003: Programatically determine if a variable exists in a data
> > set
> > >>> http://support.sas.com/kb/26/003.html
> > >>>
> > >>> Scott Barry
> > >>> SBBWorks, Inc.
> > >>>
> > >
> > >As a courtesy for subscriber privacy, reply on-list only, so that all
> > >subscribers might have an opportunity to respond to your post/reply.
> > >
> > >Thank you, Scott
> >
> >
> > Your technical approach to addressing the situation with OPEN will
> > determine
> > the impact - however you will likely only want to execute the test once,
> > building a list of variables to use with your SAS application program.
> >
> > Scott Barry
> > SBBWorks, Inc.
> >
>
|