BookmarkSubscribeRSS Feed
hmlong25
Obsidian | Level 7

Reminder: If you restarted your SAS session, you must recreate the MC1 library so you can access your practice files. In SAS Studio, open and submit the libname.sas program in the EMC1V2 folder. In Enterprise Guide, run the Autoexec process flow.

  1. Open m104p01.sas from the practices folder. Review and submit the program. Verify that it generates a report for Gold customers that contains 680 rows.


  2. Convert the code to a macro named Customers that accepts a positional parameter named Type.
    • Submit the macro definition and review the log to verify that the macro compiled successfully.
    • Call the Customers macro with the parameter value Gold. Verify that the title is Gold Customers and that there are 680 rows in the report.
    • Call %Customers again with the parameter value High Activity. Verify that no rows were selected due to a case difference.

    Solution:
    %macro customers(type); 
    title "&type Customers"; 
    proc sql number;
    select Name, Age_Group, Type 
        from mc1.customers 
        where Type contains "&type"; 
    quit; 
    title;
    %mend customers;
    
    %customers(Gold)
    %customers(High Activity)
2 REPLIES 2
PaigeMiller
Diamond | Level 26

What does the log say? Turn on the macro debugging options first by running this command

 

options mprint;

 

and then run the macro again. That should help you debug it. If you still can't figure it out, please copy and paste the log as text into the window that appears when you click on the </> icon. We need to see the entire log for the calls to the macro, not selected parts of the log.

PaigeMiller_0-1715196634946.png

--
Paige Miller
hmlong25
Obsidian | Level 7
I had to restart my computer and then the report ran. thank you for that other option I will try!

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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