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


%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)

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.

View solution in original post

5 REPLIES 5
Astounding
PROC Star

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.

arun1234
Calcite | Level 5
%macro ordata(month,year);
proc print data="/folders/myfolders/macro/order_fact.sas7bdat";
where month(Order_date) =&month and year(Order_date)=&year;
run;
%mend;
%ordata(2,2007)
working perfect
arun1234
Calcite | Level 5

%macro order_internet(month, year);
proc print data = "/folders/myfolders/macro/order_fact.sas7bdat"; ;
set work.order_fact end = eof;/* named eof.. value of eof will be 1 for last iteration */
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 = orders;
run;
%mend;
%order_internet(2,2007);

I wan to run this program could you please tell me how can I assign value to set function
Astounding
PROC Star

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. 

arun1234
Calcite | Level 5

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)

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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