BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
batnet
Calcite | Level 5

So, the following two macros work:

--To return a specified number of observations, this one works properly

%macro homework3_3 (obs=);

     options nodate nonumber;

     title "LISTING PRODUCED ON: &sysday, &sysdate9. at &systime";

     proc print data=hw3c.stocks (obs=&obs);

     run;

%mend homework3_3;

%homework3_3 (obs=5);

--To return values within a date range, and it works properly as well

%macro daterange(begindate,enddate);

     %let begindate = "&begindate"d;

     %let enddate = "&enddate"d;

     proc print data=hw3c.stocks;

     where date between &begindate and &enddate;

     run;

%mend daterange;

%daterange(05Jan2013,20Jan2013)

However, when I combine these macros with the code below:

%macro PRINT_N(begindate,enddate,obs=);

     %let begindate = "&begindate"d;

     %let enddate = "&enddate"d;

     proc print data=hw3c.stocks (obs=&obs);

     where date between &begindate and &enddate;

     run;

     %mend PRINT_N;

%daterange(05Jan2013,20Jan2013,obs=5)

I get an error message: "ERROR: The keyword parameter OBS was not defined with the macro."  I don't understand why, because I defined OBS in the same way in both this Macro and in the first Macro; it worked in Macro #1 but not in Macro #3.  What am I doing wrong?  Thanks!

Matt

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

Hi

changing

%daterange(05Jan2013,20Jan2013,obs=5)

to

%print_n(05Jan2013,20Jan2013,obs=5)

View solution in original post

2 REPLIES 2
Linlin
Lapis Lazuli | Level 10

Hi

changing

%daterange(05Jan2013,20Jan2013,obs=5)

to

%print_n(05Jan2013,20Jan2013,obs=5)

batnet
Calcite | Level 5

Wow.  That's embarrassing.  Thank you!  (Feels rather silly to make a mistake like that!)

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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