- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 05-07-2011 05:43 AM
(1611 views)
Hello all,
I would like to run the following two programs with a macro. Can somebody help me.
I need to run it for different cases (from 1 to 10), and what I need to vary from 1 to 10 are specified below.
I have basic knowledge in macros, and I appreciate your help.
Thanks
data sample1; /*sample1 to sample10*/
set sample;
if id_case=1; /*case1 to case10*/
run;
data Control;
merge Control1 /*control1 to control10*/
Sample1 ; /*sample1 to sample10*/
by ID_case;
run;
I would like to run the following two programs with a macro. Can somebody help me.
I need to run it for different cases (from 1 to 10), and what I need to vary from 1 to 10 are specified below.
I have basic knowledge in macros, and I appreciate your help.
Thanks
data sample1; /*sample1 to sample10*/
set sample;
if id_case=1; /*case1 to case10*/
run;
data Control;
merge Control1 /*control1 to control10*/
Sample1 ; /*sample1 to sample10*/
by ID_case;
run;
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Not tested:
%macro MergeCtrlSmpl;
%do case=1 %to 10;
data CTRL_&case;
merge Control&case
Sample&case (where=(id_case=&case)) ;
by ID_case;
run;
proc append base=control data=CTRL_&case force;
run;
%end;
%mend;
%MergeCtrlSmpl;
%macro MergeCtrlSmpl;
%do case=1 %to 10;
data CTRL_&case;
merge Control&case
Sample&case (where=(id_case=&case)) ;
by ID_case;
run;
proc append base=control data=CTRL_&case force;
run;
%end;
%mend;
%MergeCtrlSmpl;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Perfect, thank you very much.
It works fine.
Take care
It works fine.
Take care
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hani
Below code for SAS9.2 would allow you to get your desired result without the use of macro code at all (which I believe is always preferable):
data control;
merge sample(where=(id_case GE 1 and id_case LE 10))
control1 - control10;
by id_case;
run;
HTH
Patrick Message was edited by: Patrick
Below code for SAS9.2 would allow you to get your desired result without the use of macro code at all (which I believe is always preferable):
data control;
merge sample(where=(id_case GE 1 and id_case LE 10))
control1 - control10;
by id_case;
run;
HTH
Patrick Message was edited by: Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello Patrick,
Thanks for the suggestion, I will run it as well. I prefer not to use macros as I am not very comfortable with it.. I hope this will work as well.
Thanks
hani
Thanks for the suggestion, I will run it as well. I prefer not to use macros as I am not very comfortable with it.. I hope this will work as well.
Thanks
hani