Hi!
Yesterday I learned how to write a macro that would auto map librarys, specifically a dev and prod library for that example.
What I am trying to figure out if I can do in EG is call a macro in the Output of a task I am creating so that it will assign the library in the macro. All I seem to be able to do is manually point to a library when setting the ouput location. My goal is to create process flows where I only have to change the macro for output sets without having to change each individual task. I would assign the library to the macro in the first program task of the process flow and then the tasks reference it from there.
Do you know of any way I could make this work?
You need to keep the library name the same, it doesn't have to point to the same location in each project. All that matters is that the library name is the same.
ie project1
libname my_lib 'C:\_localdata\project1';
Project 2
libname my_lib 'C:\_localdata\project2';
Given what you're saying, I'd do it the macro variable way I suggested at first though. So the macro variable is set at the beginning of the project and set it up properly in each query.
Does creating the library depend on the task output? I'm not understanding why the macro/macrocall isn't in a program or autoexec that you then call in another program and include that as a node in your process flow.
No, all of the tasks in a particular process flow would be the library I would set in my macro. I would set it as a node as the first task in my flow and then ideally, each task would know that was the library the data set should output to. As of now, I have to browse to the library in each task to indicate where I want the output data set to go. I would like it to "know" based on the macro I set in the first node.
I hope that makes more sense.
Create a macro variable that references the library and then use that in your queries.
%let lib_day=mylib;
Then in each of the queries, point to that library which will resolve to whatever you've set it to.
&lib_day..my_data
If I use a program to write the query that works fine. Is there a way to do it using query builder like I am doing in my screenshot? I have a lot of tasks that are not programs and I simply use query builder to get the data I need for the new data sets.
So you want a library set up that defaults to where everything goes? But you don't want to type it out for each query. So these aren't process flows, its more of an everyday workflow issue?
Do you want ALL queries to go to this location? Because I think that would be the only way to default it the way you're asking.
Under Tools>Options>Output Library
Click Add
Add your library name
Move it to the top
Not exactly but maybe I can explain a little better.
So, for example.
I have 3 projects, each having a primary process flow. Each project's process flow has similar tasks, but the data sets need to be saved to different libraries depending on which project I am running. So, depending on which project I was using, I would set the macro in the first node via a program (similar to your earlier example with the %let statement). Then, ideally, all tasks in that project would save data sets to the library assigned in that macro.
In the 2nd and 3rd project, they would have different libraries assigned for their data sets to be saved to. If this worked, none of the actual tasks would ever have to be edited, just the macro for that specific project to point to its library.
From your latest example, I could set the default each time I opened a specific project, but I wouldn't be able to automate because EG would default to that library no matter which project I was using.
You need to keep the library name the same, it doesn't have to point to the same location in each project. All that matters is that the library name is the same.
ie project1
libname my_lib 'C:\_localdata\project1';
Project 2
libname my_lib 'C:\_localdata\project2';
Given what you're saying, I'd do it the macro variable way I suggested at first though. So the macro variable is set at the beginning of the project and set it up properly in each query.
Oh my... I can't believe that didn't dawn on me. Thank you soooo much. This is going to save a lot of manual work for me.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.