Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8907371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:53:57+00:00 2026-06-15T02:53:57+00:00

Hi I am trying to do a macro in sas to the following function

  • 0

Hi I am trying to do a macro in sas to the following function

I have multiple sas files(apr12part1, apr12part2,…,aug12part1,aug12part2), for each file(for example:apr12part1) , I will do some process which will give me three output(for example: apr12part1out1,apr12part1out2,pr12part1out3).

I was trying to use macro, but was not very sucssesful. Can someone help me with it? Thank you very much!
The code I was using is something like this

%macro test(month=,part=);
   ...FROM EC100002.&month_part_&part
   ...
   proc export data=SASUSER.Out1 outfile='G:\Output\Output1_&month_&part.csv' dbms=csv replace;
   proc export data=SASUSER.Out2 outfile='G:\Output\Output2_&month_&part.csv' dbms=csv replace;
   proc export data=SASUSER.Out3 outfile='G:\Output\Output3_&month_&part.csv' dbms=csv replace;
   run;
%mend test

%test(month=apr12,part=1)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:53:58+00:00Added an answer on June 15, 2026 at 2:53 am

    Try adding “dots” to concatenate the macro variables into a complete string. Also, you must use double-quotes, not single-quotes. Something like this:

    proc export data=SASUSER.Out1 
         outfile="G:\Output\Output1_&month._&part..csv" dbms=csv replace;
    

    Note there are two “dots” after your &part variable; the first is a concatenation operator and the second is part of the file name.

    You probably have similar issues with the code not displayed, so check that as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to invoke the following macro in my .cpp file: #define IAP_ROM_LOCATION
I am trying to create categorical variables in sas. I have written the following
I am trying to have a macro, on command, find the last used cell
I am trying to have a macro that will do some formatting. I need
I'm trying to optimize the following C macro: rotate(v0, v1) a0 = v0, b0
I am trying to create a macro (C/C++) to dynamically create a function. Basically
I was trying to write a macro that performed the following: For every sheet
I'm trying to work with the offsetof macro in the following way: typedef unsigned
I'm trying to create a Macro function for defining function pointers , functions etc.
I'm trying to use the TRACE macro to send the file name to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.