sas >> macro error (help please)

by everythingjake » Fri, 16 Nov 2007 04:44:14 GMT

It's been a while since I've used macros, and the hardcoded version of
this works fine. As i understand it, macro variable names require a
period only when the macro variable is the first part of the
variable. Does this prefix structure psoe any problems? Any tips for
a macro newbie?

%macro impute(var);
%if a&var=. %then a&var=0;
%if b&var=. %then b&var=0;
%if c&var=. %then c&var=0;
%if d&var=. %then d&var=0;
%if e&var=. %then e&var=0;
%mend;

data d_imputed;
set d_missing;
%impute(med1);
%impute(med2);
%impute(ill);
run;

sas >> macro error (help please)

by Kenneth M. Lin » Fri, 16 Nov 2007 06:34:08 GMT


I think you are using macro variable to refer to the actual variables in the
dataset. In that case you should be writing

if a&var = . then a&var = 0;

sas >> macro error (help please)

by data _null_; » Sat, 17 Nov 2007 00:40:05 GMT


TIP: Don't use macro language for this. There are many easier better
ways for example.

data work.missing;
call missing(amed1,bmed1,cmed1,dmed2,emed2,aill,bill);
do _n_ = 1 to 10;
output;
end;
run;
proc stdize reponly missing=0 out=work.impute;
run;
proc print;
run;

Similar Threads

1. FW: A MACRO HELP NEEDED - I am new in Macro (please help me)

> -----Original Message-----
> From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ] On
> Behalf Of Tom Smith
> Sent: Monday, May 19, 2008 1:45 PM
> To:  XXXX@XXXXX.COM 
> Subject: A MACRO HELP NEEDED - I am new in Macro (please help me)
>
> I have a sample code as below:
>
>
> %Macro select (AgB, CAB);
>
>
> if &AgB = '1' then AgB = "Aucun sympt^ome";
>      else if &AgB = "2" then AgB = "Atteinea";
>   else if &AgB = "3" then AgB = "Atteineb";
>      else if &AgB = "4" then AgB = "Atteinec";
>      else if &AgB = "p" then AgB = "Atteined";
>      else if &AgB = "q" then AgB = "Atteinee";
>     else if &AgB = "z" then AgB = "Atteinef";
> if &CAB = '1' then CAB = "Aucun sympt^ome";
>      else if &CAB = "2" then CAB = "Atteinea";
>   else if &CAB = "3" then CAB = "Atteineb";
>      else if &CAB = "4" then CAB = "Atteinec";
>      else if &CAB = "p" then CAB = "Atteined";
>      else if &CAB = "q" then CAB = "Atteinee";
>     else if &CAB = "z" then CAB = "Atteinef";
>   run;
>
> %Mend select;
> %select (Choutri, Passenger)
> run;
>
>
>
>
>
>
> Now there is a repitation of the same group of statements or group of
> codes twice ( actually
> in the original program there is hundreds time repitaion).
> How can I put
> those
> repeted statements or codes in a Macro? The program already
> has a Macro
> select.
>

Tom

When beginning to learn macro it is important to keep in mind two concepts (among others):
1. macro and data step code are run at different times.
2. macro processing is text substitution (over-simplified but essentially true).

It looks like you might be inappropriately mixing macro and data step code.  At the very least your choice of macro parameter names may be confusing.

If you want to include the macro generated statements more than once in a program then just include the macro call more than once

Data want;
  set have;
  ...
  %select(v1,v2)
  ... More statements
  %select(v3,v4)
  ...
Run;

But as Ron Fehd has pointed out, macro may not be the tool that you want to use to solve your problem.  Why are you using macro code at all here.  What is the problem that macro is supposed to solve for you that you can't use plain old data step code for?

If you tell us more about what you are trying to accomplish, someone may be able to give you better advice.

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA  98504-5204

2. A MACRO HELP NEEDED - I am new in Macro (please help me)

3. please help me to solve this ERROR: Error fetching from

4. A Macro help - Very urgent- Please help

5. Please help a new guy....SAS DI - An error occured while

That sounds like some problems with the WORK library or some other space
problems. Where are your libraries (also the metadata repository and all
the others)? How much freespace is on that disk(s)?
Don't know for sure, but that might be a thing to look for...
Gerhard



On Thu, 17 Apr 2008 08:17:34 -0700, Hypnotik < XXXX@XXXXX.COM >
wrote:

>Hi All,
>
>This is message I recieve when I run a job through DI (no its not a
>typo)
>
>The job states it has ran succesfully although I then recieve this
>message.
>
>Within my job are 4 sql joins and then an external transfer to a text
>file.
>If I limit my observations to 100,000 or 1,000,000 records the job
>works fine and I recieve a log and my file extracts fine.
>
>If I then use the full file which are two, one of 40 million and one
>of 16 million, then I recieve this error which I am assuming is
>aborting somewhere.
>
>I had some original code which I ran in Base Sas and converted to work
>in DI which works fine with these larger volumes and does not give me
>an error.
>
>Any ideas, if you need more info please give me a shout.
>
>Chris

6. Please Help: Ridge Estimator and MSE (Mean Square Error)

7. IML Error - Please Help

The message is telling you that the variable PHI is not defined
when the Probit function is called.

Ian.


----- Original Message -----
From: "Ricardo G Silva" < XXXX@XXXXX.COM >
To: < XXXX@XXXXX.COM >
Sent: Thursday, November 09, 2006 1:22 PM
Subject: IML Error - Please Help


> In running the code below I got the folowing error:
>
> ERROR: (execution) Matrix has not been set to a value.
>
> The code is:
>
> PROC IML;
> /*DEFINING A BINOMIAL  INTEGRAND*/
> START FUN(rho) ;
> N =3D1000  ;                                                             =20
> /*(CASES)       */
> DEFAULTS =3D10  ;                                         /*(DEFAULTS) */
> PD =3D0.01    ;                                           /*(TAX OF=20
> DEFAULT)*/
> RHO0=3D0.01;                                                      /*INIT*/
> BETA =3DPROBIT(PD)   ;
> PRINT BETA;
> X =3DPROBIT(PHI) ;
> PRINT X;
> S=3D (BETA-SQRT(RHO)*X)/SQRT(1-RHO);
> PRINT S;
> PP=3D PROBNORM(S);
> PRINT PP;
> LL=3DPROBBNML(PP,N,DEFAULTS);
> RETURN (LL);
> PRINT LL;
> FINISH;
> /*CALL QUAD*/
> A   =3D {0 1 };
> CALL QUAD(Z, "FUN", A)  ;
> PRINT Z;
> DO I=3D1 TO 50;
>                RHO=3DI/100;
>                LIMITE=3D {0 500};
>                CALL QUAD(LIKE,"FUN",LIMITE);
>                LOGLIKE[I] =3D LOG(LIKE);=20
> END;
> store;
>
> QUIT;
>
> Thanks
> =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=
> =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F
> Ricardo Gon=E7alves Silva, M. Sc.
> Apoio aos Processos de Modelagem Matem=E1tica
> Econometria & Inadimpl=EAncia
> Serasa S.A.
> (11) - 6847-8889
>  XXXX@XXXXX.COM 
>

8. Please help me with this error message