BookmarkSubscribeRSS Feed
InfoAlisaA
Calcite | Level 5

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

2 REPLIES 2
Hima
Obsidian | Level 7

can you paste the log?

InfoAlisaA
Calcite | Level 5

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!

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1729 views
  • 0 likes
  • 2 in conversation