BookmarkSubscribeRSS Feed
Hani
Calcite | Level 5
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;
4 REPLIES 4
Patrick
Opal | Level 21
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;
Hani
Calcite | Level 5
Perfect, thank you very much.
It works fine.
Take care
Patrick
Opal | Level 21
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
Hani
Calcite | Level 5
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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1053 views
  • 0 likes
  • 2 in conversation