BookmarkSubscribeRSS Feed
MTeck
Calcite | Level 5

Hello.

i have problem when running risk set sampling macro.

i  found this macro on this(http://mchp-appserv.cpe.umanitoba.ca/Upload/SAS/risk_set_sampling_macro.sas.txt)

 

this is my marco typing on SAS

%risk_set_match (cohort_name = CASE_CTRL,
                       outcome_var = outcome,
                       end_fu = END_EPI,
                       randnum = 123,
                       K = 20,
         control_index_dt = case_fu,
         rs_match_where = a.sex=b.sex
         id = JID,
         time0 = START_EPI,
         gender = sex,
         agevar = age,
         output_name = matched1,
         no_match = N
                      );

 

In the middle of macro, there is

-----------------------------------------------------------

   proc sql;
      create table risk as
      select
    a.&id. as case_ID,
             b.&id. as control_ID,
    a.&agevar. as case_age,
          b.&agevar. as control_age,
             a.&gender. as case_sex,
             b.&gender. as control_s,
             a.&time0. as case_t0,
             b.&time0. as control_t0,
          a.&end_fu. as case_endfu,
             b.&end_fu. as control_endfu,
          a.caco as case_caco,
          b.caco as control_caco,
             a.index_date,
             a.match_num
      from case_caco1_I a,
           controls b
      where &rs_match_where;
   quit;

   proc append base = risk_set data = risk;
   run;

----------------------------------------------------------------

In here such as case_ID, from ~~~, i have got errors.

ERROR 22-322 ~~~~

 

please answer me TT

 

1 REPLY 1
ballardw
Super User

Before running the macro set options MPRINT; so you can see the code generated by the macro. The error message will then appear in a better context indicating the issue.

 

If you retyped the code then double check on spelling and punctuation. If you added any comments using the *<text>; then replace them with either /* <text> */ or the macro specific %*<text>; as in line comments can be interpreted by the macro processor.

 

If you didn't type or modify the code then very carefully check that your data matches ALL of the requirements for the use of the macro.

 

If you can't figure out the error looking at the mprint output in the log then copy the entire output from the log and paste into a code box on the forum opened using the {I} icon. This last is important as the main message windows will reformat text making the position of the diagnostic characters that typically accompany errors like 22-322 shift a being less useful.

 

 

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
  • 366 views
  • 0 likes
  • 2 in conversation