BookmarkSubscribeRSS Feed
Mike2017
Calcite | Level 5

Here is what I'm trying to accomplish (and this may be simple, so I apologize if I'm asking a basic question...please forgive me!)

SAS Program #1 - Program I am coding for a new, specific research project.

SAS Program #2 - Program code that I routinely run for all of my research projects.

Historically, I have run #1, dumped the working dataset out, switched over to #2, processed the data through #2, dumped it back out, and re-imported it back into #1.  Is there a way I can code #1 so that it automatically loads in #2, runs the data inside of #1, and keeps right on going so that I do not have to manually stop #1, dump to #2, run #2, dump back to #1, import back into #1?

Example:  Program #1

Variables:          Date     Assets     Liabilities     Equity     Revenue     Expenses

                         2005     $1,000     $500               $500     $1,000          $750

                         2006     $1,100     $600               $500     $1,500          $900

                         2007     $1,500     $800               $700     $2,000          $1,200

In Program #2, it is coded to calculate (just an example, obviously it's a much more lengthy/complicated code that I update all the time so I want the newest version of #2 to always run on any of my other projects) Net Income, as follows:

Net Income = Revenue - Expenses;

Once #2 calculates Net Income, it exports the data, then I re-import back to #1 and continue.  I'd like to find a way to automate this.  Any tips?

Thanks!!!

2 REPLIES 2
jakarman
Barite | Level 11

When it is just for calculating some value  out of some other variables that there are many options.

1- build a macro library for including needed code modifications.

    When going macrotized that can be build to an very advanced level

2- use the %include statement  -  %inc fileref(menber) ;  - for bringing in building blocks of code.

   Doing this the code blocks must be very standardized and simple. The technical solution is that simple

3- use FCMP or other precompiled function options.     

---->-- ja karman --<-----
Ksharp
Super User

It sounds like you need to make a macro . Check:

%do i=1 %to N ;

Program #1

Program #2

%end;




%do %while();

Program #1

Program #2

%end;





%do %until();

Program #1

Program #2

%end;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 662 views
  • 0 likes
  • 3 in conversation