Date: Tue, 17 Oct 2006 21:20:41 -0700
Reply-To: David L Cassell <davidlcassell@MSN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: David L Cassell <davidlcassell@MSN.COM>
Subject: Re: Macro + Surveyselect
In-Reply-To: <003b01c6f24f$b9f4e390$73c0fea9@zifirinu>
Content-Type: text/plain; format=flowed
renata_matos@YAHOO.COM.BR wrote:
>
>Here's what I'm trying to do:
>
>
>
>%macro amostra(banco,quantidade,tamanho);
>
>proc surveyselect data=&banco out=amostra rep=&quantidade sampsize=&tamanho
>noprint;
>
>run;
>
>proc print data=amostra;
>
>run;
>
>%mend amostra;
>
>
>
>%macro teste(banco,k);
>
>%nobscat(&banco);
>
>proc iml;
>
>/* #observations */
>
>use nobs;
>
>read all into n;
>
>close nobs;
>
>print n;
>
>/* samples*/
>
>ji=0.1*(n/&k);
>
>js=0.5*(n/&k);
>
>quantidade=int((ji+js)/2)+1;
>
>print ji js quantidade;
>
>/* HERE'S THE PROBLEM! */
>
>%amostra(&banco,quantidade,5);
>
>%mend teste;
>
>
>
>%teste(refin,2);
>
>run;
>
>quit;
>
>
>
>Here's the Log:
>
>NOTE: Line generated by the invoked macro "AMOSTRA".
>
>1 proc surveyselect data=&banco out=amostra rep=&quantidade
>sampsize=&tamanho noprint;
>
>--------
>
>202
>
>1 ! run; proc print data=amostra; run;
>
>ERROR 202-322: The option or parameter is not recognized and will be
>ignored.
>
>NOTE: Line generated by the macro variable "QUANTIDADE".
>
>1 quantidade
>
>----------
>
>22
>
>ERROR 22-322: Expecting an integer constant.
>
>Thanks for any help.
>
>Renata Matos
When you're starting out with macro coding, always think about what
the code should be first, then work out how to macro-ize it.
Here, you need to use the global option MPRINT so that all your
macro code is printed out in the log and you can see how it looks.
If you do that, you'll see that you have IML code with a PROC
SURVEYSELECT stuck in the middle of it. Obviously, that won't
work. The best you can do is create the replicated data set, and
*then* run the IML code on that replicated file.
So.. why do you want to use IML, and why do you want to use
PROC SURVEYSELECT, and what is the goal of your efforts? If
you explain what the 'big picture' is, someone may be able to
give you better advice.
HTH,
David
--
David L. Cassell
mathematical statistician
Design Pathways
3115 NW Norwood Pl.
Corvallis OR 97330
_________________________________________________________________
Find a local pizza place, music store, museum and more…then map the best
route! http://local.live.com?FORM=MGA001
|