Help using Base SAS procedures

Automation with Macros

Reply
Frequent Contributor
Posts: 90

Automation with Macros

Hello Everyone,

I am working on a problem where I have to take the problem that I worked on earlier and automate it through creating macros.

I need to take the values of Country and Purchases in my script and modify those to where it writes the first returned row into a macro called Country and Country_Purchases.

This is my first attempt at this script:

%let Purchases=sum(Total_Retail_Price);

proc sql noprint inobs=1;

title '2007 Purchases by Country';

   select distinct c.Country, &Purchases as Purchases

      into:Country, :Country_Purchases

      from orion.Order_Fact as o,

           orion.Customer as c

      where o.Customer_ID=c.Customer_ID and

            year(Order_Date)=2007

            group by c.Country

            having &Purchases>1

      order by calculated Purchases desc;

quit;

I know this is completely wrong as far as reading the first returned row into a macro.

Could someone let me know where I am going wrong with this?

Thanks!

Alisa

Regular Contributor
Posts: 233

Automation with Macros

can you paste the log?

Frequent Contributor
Posts: 90

Automation with Macros

Hi Hima,

Well, I found on one of the programming documents that I needed to do this with my code:

%let Purchases=sum(Total_Retail_Price);

proc sql noprint;

title '2007 Purchases by Country';

   select distinct c.Country, &Purchases as Purchases

      into:Country1, :Country_Purchases1

      from orion.Order_Fact as o,

           orion.Customer as c;

quit;

Now, I'm having another problem with the second part of the question which I'll create another post for.

Thanks for replying!

Ask a Question
Discussion stats
  • 2 replies
  • 117 views
  • 0 likes
  • 2 in conversation