Hi everyone,
I have a program which uses the macro variable &num to do a bunch of stuff (the purport of the program is not really relevant to my question). &num is set by hand.
I want to set up some automated runs of my program. I know how to do this, but my question is this: I'll be doing lots of runs of the program and changing &num each time (but not making any other changes). Is there a more efficient way to set this up than:
1. Make manual change to &num
2. Let automatic run happen as scheduled
And repeat this process for each new instances of &num?
Any help is much appreciated!
Just one macro variable, that's all that changes?
What determines in your mind (not in SAS) what the value of &num will change to?
The program processes files and &num is in the file name.
@Walternate wrote:
The program processes files and &num is in the file name.
I don't think this answers my questions.
@Walternate wrote:
The program processes files and &num is in the file name.
The generated file name? Or the input file name? Does it follow an increment schedule? Randomly assigned? Or magically assigned?
Where to do the "new instances of &num" come from? Are these values in a data set? Based on a calendar date? The phase of the moon? Armenian Fiscal Years?
Without knowing where values for &num come from there is no way this can be automated.
I receive input files to be processed by the program and &num is in the name of the input file, eg: Listing of files in directory &num.xlsx .
So are you saying that you receive a file, here is a possible name of the file:
Listing of files in directory 16.xlsx
And then in your program you want to use 16?
Is this Excel file in a specific folder, where its name can be read by your program and parsed? Are there ever other Excel files in that folder?
Please explain the process by which this file is found in detail, rather than have us ask lots of questions. Don't be brief with your explanations, don't be stingy with information. We're trying to help you but you have to help us.
SAS provides several ways to pick up data from the "outside".
You can add
-sysparm="string"
to the commandline and then use the SYSPARM function or the &SYSPARM automatic macro variable.
Or (and this is what schedulers do) set environment variables and retrieve those with the SYSGET data step function or %SYSGET macro function.
Script file (if on UNIX)
export NUMBER=16 sas program.sas
In the program,
%let number = %sysget(NUMBER);
will set the macro variable number to 16.
On Windows, use the set command in the batch file.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.