The macro doesn't display anything, it inserts value into your table. Check your table.
Sorry I meant when I check my table I have a lot of -2, 0 -1, 1 but I don't have decimal numbers.
@Num19 wrote:
Sorry I meant when I check my table I have a lot of -2, 0 -1, 1 but I don't have decimal numbers.
Since you only insert a couple of variables into your table you won't have much info for diagnostics.
Likely to generate a lot of junk but try running
Options mprint symbolgen;
before the macro. I could show where your values aren't being kept or such.
Also what does the %module_2 macro actually look like? That might be the cause since it is setting the value of one of your variables. If it sets a large value for norm then you may not have many times when norm< seuil at the test for insertion.
Here is module's code :
%macro module_2(x_1,y_2); %global norme_2; %let xcarre=(&x_1**2); %let ycarre=(&y_2**2); %let normecarre=%sysevalf(&xcarre+&ycarre); %let norme_2=%sysfunc(sqrt(&normecarre)); %mend module_2; %module_2(2,3);
missing %sysevalf here mate!
%let xcarre=(&x_1**2); %let ycarre=(&y_2**2);
@Num19 wrote:
Here is module's code :
%macro module_2(x_1,y_2); %global norme_2; %let xcarre=(&x_1**2); %let ycarre=(&y_2**2); %let normecarre=%sysevalf(&xcarre+&ycarre); %let norme_2=%sysfunc(sqrt(&normecarre)); %mend module_2; %module_2(2,3);
And use in the other code as this macro is written would be more like:
%module_2(&u., &v.);
%let norm=&norme_2.;
Since the macro module_2 does not return a single value but defines a global macro variable to hold the result.
If you want to use %module_2 as function returning value rewrite it as:
%macro module_2(x_1,y_2); %global norme_2; %let xcarre=%sysevalf(&x_1**2); %let ycarre=%sysevalf(&y_2**2); %let normecarre=%sysevalf(&xcarre+&ycarre); %sysfunc(sqrt(&normecarre)) %mend module_2; %put result of %module_2(2,3);
The %put is just to demonstrate it behaves more like a function. After debugging you could reduce that to
%macro module_2(x_1,y_2); %sysfunc(sqrt(%sysevalf(%sysevalf(&x_1**2)+%sysevalf(&y_2**2)))) %mend module_2;
I would highly, highly recommend changing the 'module_2' portion to a function using PROC FCMP and to change this to a data step process. It'll much easier to manage, expand and likely faster.
Why would you even attempt to do something like this using the macro processor?
Why not just write a data step to implement this logic?
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.