From: renju on
Hi I am new to SAS programing world...But i have some prior experience
in programing languages...I have some doubts with Array..Please help
me to solve it out...
My doubts is
Can we pass array as parameter to macro function..if its possible
then how to access its values...?????

The following is my code..Hope you will understand my problem...
/******************* Program Start ********************************/

%macro dataset_format(ds,ds_name,dummy_status,names_a,title,ord);
/*** in above parameters list 'names_a' is an array
but i am facing difficulties to get its values in opencode
and inside data step *****/
put &names_a(1,1);** this statement works(can access the value) in
open code but not inside data step..;
data &ds_name;
run;
%mend dataset_format;



data _NULL_(LABEL="Age1234");
array age(5,3) $50. _temporary_
( "N","n","1"
"Mean","Mean","2"
"SD","SD","3"
"Median","Median","4"
"minmax","Min , Max","5"
);
%let title=Age1 (Years);
%let ord=4;
%dataset_format(age4,age5,0,age,&title,&ord)**here age i am passing as
an array...;
run;

/******************* Program End ********************************/





From: Tom Abernathy on
Macro code is for manipulating text strings to generate SAS code.
What you seem to be trying to describe as an ARRAY below looks like a
SAS dataset to me. If you need to pass that into your macro then save
it as a SAS dataset and pass the name of the dataset to the macro so
that the generated SAS code can operate on the data.
Once you have figured out how to manipulate the data using SAS you can
begin to identify the pieces that change from problem to problem and
create a macro takes those input in order to generate the SAS code to
do what you want.


On Jun 1, 12:49 pm, renju <renju.webmas...(a)gmail.com> wrote:
> Hi I am new to SAS programing world...But i have some prior experience
> in programing languages...I have some doubts with Array..Please help
> me to solve it out...
> My doubts is
>   Can we pass array as parameter to macro function..if its possible
> then how to access its values...?????
>
> The following is my code..Hope you will understand my problem...
> /******************* Program Start ********************************/
>
> %macro dataset_format(ds,ds_name,dummy_status,names_a,title,ord);
> /*** in above parameters list 'names_a' is an array
>      but i am facing difficulties to get its values in opencode
>      and inside data step *****/
> put &names_a(1,1);** this statement works(can access the value) in
> open code but not inside data step..;
> data &ds_name;
> run;
> %mend dataset_format;
>
> data _NULL_(LABEL="Age1234");
> array age(5,3) $50. _temporary_
>  (    "N","n","1"
>     "Mean","Mean","2"
>     "SD","SD","3"
>     "Median","Median","4"
>     "minmax","Min , Max","5"
>   );
> %let title=Age1 (Years);
> %let ord=4;
> %dataset_format(age4,age5,0,age,&title,&ord)**here age i am passing as
> an array...;
> run;
>
> /******************* Program End ********************************/

From: renju on
Thank you...But i still have the doubt whether we can pass the array
to macro or not ??????????
On Jun 2, 4:58 am, Tom Abernathy <tom.aberna...(a)gmail.com> wrote:
> Macro code is for manipulating text strings to generate SAS code.
> What you seem to be trying to describe as an ARRAY below looks like a
> SAS dataset to me. If you need to pass that into your macro then save
> it as a SAS dataset and pass the name of the dataset to the macro so
> that the generated SAS code can operate on the data.
> Once you have figured out how to manipulate the data using SAS you can
> begin to identify the pieces that change from problem to problem and
> create a macro takes those input in order to generate the SAS code to
> do what you want.
>
> On Jun 1, 12:49 pm, renju <renju.webmas...(a)gmail.com> wrote:
>
> > Hi I am new to SAS programing world...But i have some prior experience
> > in programing languages...I have some doubts with Array..Please help
> > me to solve it out...
> > My doubts is
> >   Can we pass array as parameter to macro function..if its possible
> > then how to access its values...?????
>
> > The following is my code..Hope you will understand my problem...
> > /******************* Program Start ********************************/
>
> > %macro dataset_format(ds,ds_name,dummy_status,names_a,title,ord);
> > /*** in above parameters list 'names_a' is an array
> >      but i am facing difficulties to get its values in opencode
> >      and inside data step *****/
> > put &names_a(1,1);** this statement works(can access the value) in
> > open code but not inside data step..;
> > data &ds_name;
> > run;
> > %mend dataset_format;
>
> > data _NULL_(LABEL="Age1234");
> > array age(5,3) $50. _temporary_
> >  (    "N","n","1"
> >     "Mean","Mean","2"
> >     "SD","SD","3"
> >     "Median","Median","4"
> >     "minmax","Min , Max","5"
> >   );
> > %let title=Age1 (Years);
> > %let ord=4;
> > %dataset_format(age4,age5,0,age,&title,&ord)**here age i am passing as
> > an array...;
> > run;
>
> > /******************* Program End ********************************/