Date: Wed, 18 Apr 2007 13:13:26 -0400
Reply-To: Jake Bee <johbee@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jake Bee <johbee@GMAIL.COM>
Subject: Re: What's wrong with this macro again ?
In-Reply-To: <82FD85BED187814D8BB11E7DFE35098D24F8E9@sh0cx691.prod.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Well, I think I need some data to trace this, and there could be a
parenthesis or something else missing which prevents the marcro from
executing. But a couple of questions, you are setting a data _null_ into a
dataset - not sure if this does anything. You have a merge without a by
statement which could be a problem once the other issues are cleaned up.
Could you give some example data, and the example call to the macro?
Jake
On 4/18/07, Elmaache, Hamani <Hamani.Elmaache1@cra-arc.gc.ca> wrote:
>
>
> Hi Jake and every body there.
> My problem is with this macro: NO ERRORS IN THE LOG, but It doesn't work.
> I spent a lot time to figure out why. I didn't find any mistake.
> Please, can you give a look at It? I appreciate any help.
>
> Thank you very much in advance.
>
>
> /**************************************************************************************/
>
> options symbolgen mprint;
> %macro selection (dataset= , smalsize= ,totalsize= , number= );
> %global indepdnt;
> %put " this is totalsize=&totalsize" ;
> /*******************************************/
> %do i=&smalsize %to i=&number by &smalsize;
> %put "Show itirations =&i " ;
> /**************************/
> data pred&i again&i ;
> set &dataset ;
> if _N_<=&smalsize then output pred&i ;
> else output again&i;
> run;
>
> %put pred&i;
> /**************************/
> data pred5000; set _null_; run;
> /**************************/
>
> data pred5000;
> merge pred5000 pred&i;
>
> /***************************************************************************************/
> data again&i(keep=&key &indepdnt unit1 );
> SET again&i; run;
> /*******************************************/
> PROC IML;
> use again&i;
> read all var {unit1 &indepdnt } INTO dat_pred1;
> use again&i;
> read all var {&key &indepdnt } INTO dat_pred;
>
> /****************************/
> USE Parest;
> READ ALL VAR {intercept &indepdnt } INTO Parest1;
> prob1=1/(1+exp(-dat_pred1*T(Parest1)));
> /********************************/
>
> pred_NCOMP=dat_pred||prob1;
> /********************************/
> varPhat={ &key &indepdnt prob1 };
> create pred_NCOMP from pred_NCOMP[COLNAME=varPhat];
> append from pred_NCOMP;
> quit;
> /*******************************************/
> proc sort data=pred_NCOMP out=pred_NCOMP;
> by descending prob1;
> run;
> /*******************************************/
>
> %let i=%eval(&i+&smalsize);
> %if %eval(&i) <= %eval(int(&totalsize/&smalsize)) %then %do;
> data pred&i again&i ;
> set &dataset ;
> if _N_<=&smalsize then output pred&i ;
> else output again&i;
> data pred5000;
> merge pred5000 pred&i ;
> run;
>
> %end;
>
> %end;
> %MEND selection;
>
>
>
> /***************************************************************************************/
>
> /***************************************************************************************/
>
> -----Original Message-----
> *From:* Jake Bee [mailto:johbee@gmail.com]
> *Sent:* April 17, 2007 2:20 PM
> *To:* Elmaache, Hamani
> *Cc:* SAS-L@listserv.uga.edu
> *Subject:* Re: What's wrong with this macro?
>
> You may just may be a little confused as to which way to look at the
> problem. So two examples are given to illustrate at least 2 views. But
> unless this is an exercise to build a more complex macro a macro is not
> needed here.
> Regardless, testing the different views is useful.
>
> dm 'out' clear;
> dm 'log' clear;
>
> options symbolgen mprint;
>
> data a;
> length id $4 sex $1;
> id='1001'; sex='F'; output;
> id='1002'; sex='M'; output;
> run;
>
> %macro makeds_ex1(ds=, male=male_ds, female=female_ds);
> data &female ♂
> set &ds;
> if sex='F' then output ♀
> else output ♂
> run;
> %mend makeds_ex1;
>
> %makeds_ex1(ds=a);
>
>
> %macro xmakeds_ex2(ds=,gender=);
>
> %local out_ds;
>
> %if &gender eq F %then
> %do;
> %let out_ds=female;
> %end;
> %else
> %do;
> %let out_ds=male;
> %end;
>
> data &out_ds;
> set &ds;
> %if &gender eq M %then
> %do;
> if sex='M';
> %end;
> %else
> %do;
> if sex='F';
> %end;
>
> output &out_ds;
>
> run;
>
> %mend xmakeds_ex2;
>
> %xmakeds_ex2(ds=a, gender=M);
> %xmakeds_ex2(ds=a, gender=F);
>
>
>
>
> On 4/17/07, Elmaache, Hamani <Hamani.Elmaache1@cra-arc.gc.ca> wrote:
> >
> > Thank you very much SAS users.
> > I did:
> > Change %if to if, %then to then, and %else to else
> >
> > It works, but it doesn't work whith these %if and %then and %else.
> >
> >
> >
> >
> > -----Original Message-----
> > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]
> > Sent: April 17, 2007 12:24 PM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: Re: What's wrong with this macro?
> >
> >
> > Change %if to if, %then to then, and %else to else. Other than that, it
> > is difficult to see any other problem without seeing your call to the
> > macro.
> >
> > Cliff
> >
> > -----Original Message-----
> > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> > Elmaache, Hamani
> > Sent: Tuesday, April 17, 2007 12:12 PM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: What's wrong with this macro?
> >
> > Can someone run this macro and tells me hat's wrong with it?
> >
> > Thanks a lot.
> >
> >
> > options symbolgen mprint;
> > %macro makeds(ds=, male=, female=);
> > data &female ♂
> > set &ds ;
> > %if sex='F' %then output &female ;
> > %else output &male ;
> > run;
> > %mend makeds;
> >
> > ----------------------------------------------------------------------
> > LEGAL NOTICE
> > Unless expressly stated otherwise, this message is confidential and may
> > be privileged. It is intended for the addressee(s) only. Access to this
> > E-mail by anyone else is unauthorized. If you are not an addressee, any
> > disclosure or copying of the contents of this E-mail or any action taken (or
> > not taken) in reliance on it is unauthorized and may be unlawful. If you
> > are not an addressee, please inform the sender immediately.
> >
>
>
|