Date: Wed, 18 Apr 2007 12:41:23 -0400
Reply-To: "Gerstle, John (CDC/CCID/NCHHSTP) (CTR)" <yzg9@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Gerstle, John (CDC/CCID/NCHHSTP) (CTR)" <yzg9@CDC.GOV>
Subject: Re: What's wrong with this macro again ?
In-Reply-To: <82FD85BED187814D8BB11E7DFE35098D24F8E9@sh0cx691.prod.net>
Content-Type: text/plain; charset=us-ascii
Hamani,
If there are no errors in the Log, that means the code is not violating
any SAS rules, per se. If the result is not what you want, then the code
needs to be modified to do so. Please post what you desire in the
output. I would guess that the code for the macro is fine; it's the
programming logic that is incorrect resulting in something you don't
want. Without know what you want, it's guesswork on our part to provide
a solution.
BTW
>> %do i=&smalsize %to i=&number by &smalsize;
Change this to:
>> %do i=&smalsize %to &number by &smalsize;
John Gerstle
MS Applied Neuroscience, MS Applied Statistics
Biostatistician
Northrop Grumman
CDC Information Technological Support Contract (CITS)
NCHSTP \DHAP \HICSB \Research and Dissemination Team
Centers for Disease Control and Prevention
>>-----Original Message-----
>>From: owner-sas-l@listserv.uga.edu
[mailto:owner-sas-l@listserv.uga.edu]
>>On Behalf Of Elmaache, Hamani
>>Sent: Wednesday, April 18, 2007 12:05 PM
>>To: Jake Bee
>>Cc: SAS-L@listserv.uga.edu
>>Subject: What's wrong with this macro again ?
>>
>>
>>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.
|