Date: Wed, 27 Feb 2008 11:54:00 -0800
Reply-To: NM <neerav.monga@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: NM <neerav.monga@GMAIL.COM>
Organization: http://groups.google.com
Subject: Re: null dataset testing in macro
Content-Type: text/plain; charset=ISO-8859-1
Hi,
Ok , I understand that it only assigns a zero when it immediately
encounters the EOF.
As for what my program is doing, the program is now working using the
code provided. All i needed to add was %if &nulldata ^=0 %then %do and
my B macro won't work.
My program is creating chi square values based on each level of the
various 27 variables (in a nutshell) so I'm a) looping through the
variables b) looping through the levels of each variables. If certain
values are missing, I run into this null dataset issue hence the
discussion.
Thanks for taking time out of your busy day everyone for the help!
On Feb 27, 12:15 pm, datan...@GMAIL.COM ("data _null_,") wrote:
> On Wed, Feb 27, 2008 at 11:47 AM, NM <neerav.mo...@gmail.com> wrote:
> > Ok, I see your point...However, isn't your program hard coding _n_ to
>
> Actually no, it is assigning _N_=0 when EOF=1. Otherwise _N_=1.
> However we don't need that because we can just use EOF directly as
> follows.
>
> data _null_;
> call symputX('hasdata',not eof);
> stop;
> set end=eof; *include data set name here, if _LAST_ does not work;
> run;
>
> > = 0? My program creates temp, runs proc freq, outputs it, then creates
> > temp again (using a new variable) etc... In total I have 27 temp
> > datasets (based on 27 variables) that are rewritten. Won't your code
> > simply make all of them null if you recode _n_=0? I know that out of
> > 27 temp datasets, only 2 are null, and that is where I don't want to
> > process my "B" macro, but for the other 25 temp datasets, i want "B"
> > to run.
>
> > Maybe I'm just missing something here, but I think we're still a step
> > away.
>
> Condsider this macro that creates CLASS, 5 times. Every other time it
> REMOVES the records from CLASS. HASDATA is assigned as above. So if
> I understand the question no there is not a problem with the method.
>
> %macro test;
> %local I hasdata;
> %do i = 1 %to 5;
> data class; set sashelp.class(obs=1); run;
> %if %sysfunc(mod(&i,2)) eq 0 %then %do;
> data class; modify class; remove; run;
> %end;
> data _null_;
> call symputX('hasdata',not eof);
> stop;
> set end=eof;
> run;
> %put NOTE: I=&i HASDATA=&hasdata;
> %end;
> %mend test;
> options mprint;
> %test;
> run;
>
> Having said all that, you say
>
> > runs proc freq, outputs it, then creates
> > temp again (using a new variable) etc... In total I have 27 temp
> > datasets (based on 27 variables) that are rewritten.
>
> This makes me think that you could accomplish this task more easily
> without macro looping and all this checking....
>
> Can you describe what you are trying to accomplish not the way you are doing it?
> Perhaps provide example data and desired output.
|