Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling a macro from a data step

Status
Not open for further replies.

juanvg1972

IS-IT--Management
Dec 24, 2008
10
ES
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;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top