input amt number no;
78797 879 1
1215 756 2
12125 963 3
145 782 4
1245 712 160
254 740 161
I want to pass them into macro vaiables like if No=1 then amt should
if no=1 call symput('A1',amt) ;
if no=1 call symput('B1',number);
if no=161 call symput('A161',amt) ;
if no=161 call symput('B161',number);
i want to do for all the obs as i am having many obs any one can help by using array.I wnat all these macro variables as i wnat to do multipilcation based on No.
if no=1 then amt=amt+3 and number=number+3*.30;
so i need these macro for every obs
You should explain why you think that creating that many macro variables is necessary. The macro-variables name can be created by appending the dataset variable "no" to the appropriate letter.
call symput(cats('A', no), amt);
call symput(cats('B', no), number);
Message was edited by: andreas_lds
I'm still not convinced that you need a macro. I agree with Andreas. There are many techniques available to achieve your stated goal: "I want all these macro variables as i want to do multiplication based on No.
if no=1 then amt=amt+3 and number=number+3*.30;"
Consider the following program, that uses a FORMAT to create a variable called MULT -- based on the variable AGE -- when AGE is 11, MULT will be 2; when AGE is 13, MULT will be 6, etc:
value amult 11=2
mult = input(put(age,2.0),amult.);
newnum = height * mult;
put age= mult= newnum=;
You probably wouldn't need a format if there was some logic behind how NO=1 turned into a multiplier of 3. But even so, making a lookup list with PROC FORMAT is easier than writing a macro program when you don't need one.
Is there other processing that you are not explaining??? The title of your post was "Array", but you jumped past arrays straight into macro variables. Having numbered macro variables is NOT the same thing as building an array and using numbered macro variables in place of an array is probably not a good idea. At this point, however, I don't understand the need for either arrays or macro variables.