BookmarkSubscribeRSS Feed
Emma8
Quartz | Level 8

Hello. Can anyone help with the following report. I would like to create as the attached report by using from 1 to multiple data-sets the following macro parameters which are unique for each data-set: 

 

proc stdrate data=&DATA (data 1 and data 2).
     refdata=&REFDATA (data 1a and data 2a).
     method=direct
     stat=rate (mult=100000);
     population event=&EVENTS (for data 1 it is cancer 1 and for data 2 it is cancer 2) total=&POPULATION. (                                                                                                                             there are 2 different  variables from data-sets (data 1a and data 2a));
      reference total=&REF_TOTAL. (variable female from data  1a and overall from data 2a) ;
      strata agegroup;
      by &COHORTS (in the example, those are gender and race) notsorted;
      ods output StdRate=StdRate;

quit;
run;

 

Thank you.

1 REPLY 1
Tom
Super User Tom
Super User

Get the code to work for one set of values (datasets, variables etc).

Then change the variable part to use macro variable references (which is kind of like your posted pseudo code).  Just set the macro variable values with %LET statements at the top.  Get that to work for the same example values.

%let data=data1;
%let refdata=data1a;
....
proc stdrate 
  data=&data
  refdata=&refdata
...

Then remove the %LET statements and wrap the code into a macro using the names of those macro variables as the parameters to the macro. Convert the %LET statements into the values of the macro in the call to the macro.  Again get that to work for your example.

%macro mystdrate
(data=
,refdata=
...
);
proc stdrate 
  data=&data
  refdata=&refdata
...

%mend;

%mystdrate
(data=data1
,refdata=data1a
...
);

Then just call the macro multiple times with each of your combinations of values.

%mystdrate
(data=data2
,refdata=data2a
...
);

If you actually have the list of values in a dataset then you can use the dataset to generate the calls.  But if you don't have the dataset it is not really worth making it. Just write the individual macro calls. 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 549 views
  • 2 likes
  • 2 in conversation