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
Hi
changing
%daterange(05Jan2013,20Jan2013,obs=5)
to
%print_n(05Jan2013,20Jan2013,obs=5)
Hi
changing
%daterange(05Jan2013,20Jan2013,obs=5)
to
%print_n(05Jan2013,20Jan2013,obs=5)
Wow. That's embarrassing. Thank you! (Feels rather silly to make a mistake like that!)
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.