%macro ordata(month,year);
proc print data="/folders/myfolders/macro/order_fact.sas7bdat";
where month(Order_date) =&month and year(Order_date)=&year;
if order_type=1 then count+1;
run;
%mend;
%ordata(2,2007)
I'd suggest you try to debug this by getting rid of the macro language. Just run a PROC PRINT with hard-coded values of 2 for &MONTH and 2007 for &YEAR, and see what it takes to fix up the program.
I'd suggest you try to debug this by getting rid of the macro language. Just run a PROC PRINT with hard-coded values of 2 for &MONTH and 2007 for &YEAR, and see what it takes to fix up the program.
Here are some basics that you will need to learn.
The SET statement names the incoming SAS data set. All you have to do is give the name of the data set.
The first PROC PRINT should not be a PROC PRINT at all. The statements that follow it are not allowed within a PROC PRINT. Instead, it should probably be:
data orders;
The DATA statement names the SAS data set you would like to create, so that the second PROC PRINT can name it as the data set to be printed.
Once again, I would suggest you get rid of the macro language. Get the program to work first, without a macro. Once it works, worry about converting the program to a macro.
Thank you. I got your idea and i changed the format now it is working...
%macro order_internet(month, year);
data new;
set wombat.order_fact end=enof;
where month(Order_date) =&month and year(Order_date)=&year;
if order_type =3 then count +1;
if eof =1 and count>0 then do;
call symputx('title','Some Internet Orders'); call symputx('count',count); end;
else if eof = 1 and count = 0 then do; call symputx('title','No internet Orders'); call symputx('count',0); end;
run;
title "&title";
title2 "Total Internet Orders are &count";
proc print data = new;
run;
%mend;
%order_internet(2,2007)
%order_internet(4,2007)
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: