juanvg1972
IS-IT--Management
I'm trying to create a field in a datasets based in the value of another field.
I'm usind a macro to make se assignment of the value. Yo can see the process bellow.
The real macro is not that simplem but I'ms using it to make tests.
I expect that result:
campo1 campo2
ab 1
ac 2
but I get:
campo1 campo2
ab 1
ac 2
I'm not sure if I have any error in the method of calling a macro from a data sets
Can anybodt hepl me???, any advice would n greatly apreciatted.
----
data prueba;
length campo1 $10.;
campo1 = 'ab';
output;
campo1 = 'ac';
output;
run;
data prueba1;
set prueba;
campo2 = %valor1(campo1);
run;
%macro valor1(campo);
%if %trim(&campo) = 'ab' %then %do;
%let salida = 1;
%end;
%else %do;
%let salida = 2;
%end;
&salida;
%mend;
I'm usind a macro to make se assignment of the value. Yo can see the process bellow.
The real macro is not that simplem but I'ms using it to make tests.
I expect that result:
campo1 campo2
ab 1
ac 2
but I get:
campo1 campo2
ab 1
ac 2
I'm not sure if I have any error in the method of calling a macro from a data sets
Can anybodt hepl me???, any advice would n greatly apreciatted.
----
data prueba;
length campo1 $10.;
campo1 = 'ab';
output;
campo1 = 'ac';
output;
run;
data prueba1;
set prueba;
campo2 = %valor1(campo1);
run;
%macro valor1(campo);
%if %trim(&campo) = 'ab' %then %do;
%let salida = 1;
%end;
%else %do;
%let salida = 2;
%end;
&salida;
%mend;