f



Re: Reusing code from SAS Program in another SAS Program #7 1547527

Hi Keith,
is it exactly the same code (a) or only the same structure but with different variable names in it (b) ?

(a) you may save the "IF code" in a separate member (let's say IFcode) and simply %INCLUDE that
    member within
    your various data stes.
    FILENAME xxx
    FILENAME xxx 'a.b.c.' DISP=shr;

    DATA ...
     SET ...
     %INCLUDE xxx(IFcode);
    run;

(b) you could use the same technique but with macro logic in order to set the variable names
    dynamically before including IFcode

does this help ?

Regards Roland

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Keith
Sent: Saturday, May 21, 2005 12:23 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Reusing code from SAS Program in another SAS Program

I write SAS programs on the Mainframe.  I have several programming
steps in multiple programs that use the same IF statements, for
example.

Maintenance is getting to be a problem because I may have to make the
same code change in 50 different programs.

I would like to write the If statement only once and read it into the
appropriate data steps of the various programs.

If someone could give me help on how I could do this, it would be
appreciated.
0
5/21/2005 9:44:58 AM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

0 Replies
776 Views

Similar Articles

[PageSpeed] 19

Reply:

Similar Artilces:

Re: Reusing code from SAS Program in another SAS Program #7 647546
Ian Whitlock wrote: > %INC is neither a macro nor a macro instruction. It is one of a > few old SAS commands that begin with a %-sign and predate the > current macro language. %RUN and %LIST are two others; is that a complete list? The MACRO statement is also not disabled by OPTIONS NOMACRO, but it doesn't start with a percent sign. -- Jack Hamilton Oakland, California ...

Re: Reusing code from SAS Program in another SAS Program
Keith - Store your code snippets in a PDS and then %include into your programs. For example this program includes a format called "$REGCRT" that I've stored in the PDS DSCHEER.PROD.RUN.FORMATS($REGCRT): //LOOKUP JOB (DSDBX0000T,DS80,20,5,0),'CHOATE 654-2160',TIME=1, // USER=DSPAULC,MSGCLASS=X,NOTIFY=DSPAULC //GOSAS EXEC HWSAS //SYSIN DD * OPTIONS PS=2000 LS=80; LIBNAME VENDOR 'DS.SYS.WORK.VENDOR.PANEL' DISP=SHR; FILENAME FMT 'DSCHEER.PROD.RUN.FORMATS' DISP=SHR; %INC FMT($REGCRT); DATA LOOKUP; RETAIN SENDDATE VENDRC RCNAME VENDOR NAME ADDR1 ADDR2 ADDR3 ZIP PHONENUM INVADDR1 INVADDR2 INVZIP; SET VENDOR.PANEL; WHERE VENDOR IN ('HV0010' 'HV0011'); RCNAME=PUT(VENDRC,$REGCRT.); KEEP SENDDATE VENDRC RCNAME VENDOR NAME ADDR1 ADDR2 ADDR3 ZIP PHONENUM INVADDR1 INVADDR2 INVZIP; PROC PRINT; RUN; ENDSAS; Since %INC is a macro you can put it anywhere in open code and it will read the code snippet during compilation. hth Paul Choate DDS Data Extraction (916) 654-2160 -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Keith Sent: Friday, May 20, 2005 3:23 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Reusing code from SAS Program in another SAS Program I write SAS programs on the Mainframe. I have several programming steps in multiple programs that use the same IF statements, for example. Maintenance is getting to b...

Re: Reusing code from SAS Program in another SAS Program #5
Ian, I agree with your statement: "Well maybe it is best postponed to the time Keith shows that parameterization would be helpful to him." If it does turn out that parameterization would be helpful to him, he is in luck. I will agree to offer him, and SAS-L, the best example that my understanding of the SAS Component Language and my meager skills will allow. And I hope you, and as many other mmmm's as possible, will do likewise with the SAS Macro Language. I hope it has become apparent to you and other mmmm's that the SAS Component Language can handle whole classes of pr...

Re: Reusing code from SAS Program in another SAS Program #4
In response to a question by Keith, Paul Choate suggested using %INC. The suggestion is reasonable, but not his explanation. Since %INC is a macro you can put it anywhere in open code and it will read the code snippet during compilation. %INC is neither a macro nor a macro instruction. It is one of a few old SAS commands that begin with a %-sign and predate the current macro language. This can be shown by a batch job run with the option NOMACRO. Here is the log. NOTE: SAS (r) Proprietary Software Release 8.2 (TS2M0) Licensed to The SAS Learning Edition V2.0, Site ...

Re: Reusing code from SAS Program in another SAS Program #6 1547525
Keith, You have two choices: 1st.: create macros containing your if statements and store them either in a user or public macro library. 2nd.: Create text files contaiing your if statements save them in a PDS and %include them in your program. Toby Dunn From: Keith <kmccall00@CHARTER.NET> Reply-To: Keith <kmccall00@CHARTER.NET> To: SAS-L@LISTSERV.UGA.EDU Subject: Reusing code from SAS Program in another SAS Program Date: Fri, 20 May 2005 15:23:07 -0700 I write SAS programs on the Mainframe. I have several programming steps in multiple programs that use the same IF statements, for example. Maintenance is getting to be a problem because I may have to make the same code change in 50 different programs. I would like to write the If statement only once and read it into the appropriate data steps of the various programs. If someone could give me help on how I could do this, it would be appreciated. ...

Reusing code from SAS Program in another SAS Program
I write SAS programs on the Mainframe. I have several programming steps in multiple programs that use the same IF statements, for example. Maintenance is getting to be a problem because I may have to make the same code change in 50 different programs. I would like to write the If statement only once and read it into the appropriate data steps of the various programs. If someone could give me help on how I could do this, it would be appreciated. Keith - Store your code snippets in a PDS and then %include into your programs. For example this program includes a format called "$REGCRT...

Re: Can a SAS program call another SAS program
> From: David Fickbohm > I am writing a report that counts the number of widgets produced by > partners. I have a small routine that finds the partners id > number and > name. Obviously I could copy this code into my program and > execute it. I was wondering if there was a more elegant way > of "Calling" a SAS program > from within a SAS program. > I am running SAS 8.1 in windows. still!?!? surely that is a typo: 9.1? i.e.: -The- 9.1==9.1.3 include it: - - - subRoutineX.sas - - - *...; - - - subRoutineX.sas end - - - - - - autoexec.sas - - - filen...

Re: Can a SAS program call another SAS program #3
Dear SAS-L-ers, David Fickbohm posted the following: > I am writing a report that counts the number of widgets produced by > partners. I have a small routine that finds the partners id > number and > name. Obviously I could copy this code into my program and > execute it. I was wondering if there was a more elegant way > of "Calling" a SAS program > from within a SAS program. I am running SAS 8.1 in windows. > David, there sure is a more elegant way; and a simple one at that! Simply use the %INCLUDE statement. The %INCLUDE statement allows you to in...

Re: Possible to run a SAS program within another SAS program?
Julie, Uhhh create a macro that simply %includes the programs you want and in what order. It would be very specific to you the creator and user, in other words right biw I can't think of a good way to pass al the info you need to the macro from the user. As you can tell the user interface would be the crucial part of this. I personally wouldnt want to have this in my production code but have written SAS programs that do nothing more than %include a list of programs. Toby Dunn From: oseithedude@GMAIL.COM Reply-To: oseithedude@GMAIL.COM To: SAS-L@LISTSERV.UGA.EDU Subject: Possible to run a SAS program within another SAS program? Date: Wed, 7 Dec 2005 11:28:43 -0800 Hello, I have 9 SAS programs, all within the same Windows folder that I usually run at the same time - one right after the other. For convenience, is it possible to write a simple SAS program that will let me run all the programs at once or to have a program that will allow me to pick and choose which SAS programs I want to run (e.g., in the case I only want to run the first 3 and last program out of the 9 SAS programs) and which order the programs are run in? I guess what I'm really looking for is if there is a way to call another SAS program using only a couple lines of code so that, if I choose not run that program, I can just comment that code out or something like that. Let me know if this is possible, thanks!!! Julie ...

Re: Can a SAS program call another SAS program #2
Dave, What you want to do can be done with %include. Bob Abelson HGSI 240 314 4400 x1374 bob_abelson@hgsi.com David Fickbohm <DavidF@HOMEGAIN.COM> Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> 10/15/2004 04:05 PM Please respond to David Fickbohm To: SAS-L@LISTSERV.UGA.EDU cc: Subject: Can a SAS program call another SAS program People, I am writing a report that counts the number of widgets produced by partners. I have a small routine that finds the partners id number and name. Obviously I could copy this code into my...

Re: Possible to run a SAS program within another SAS program? #6
On Wed, 7 Dec 2005 22:32:49 -0800, oseithedude@GMAIL.COM wrote: >nevin.krishna@gmail.com wrote: >> You could use the %include statement to call a specified program. >> for example : >> >> %include "c:\documents and settings\nkrishna\my >> documents\macros\upcase_mac.sas"; >> >> where upcase_mac.sas is a program stored in the above path..so you >> could write an include statement for each program and then copy and >> paste them into any order you need..unless of course i am >> misunderstanding your needs..:-) >> >...

Re: Possible to run a SAS program within another SAS program? #3
why just last week, we discussed this: Date: Mon, 21 Nov 2005 11:01:30 -0500 Subject: Re: Running SAS programs from within a SAS program http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0511C&L=sas-l&P=R33664 Ron Fehd the %include maven CDC Atlanta GA USA RJF2 at cdc dot gov > -----Original Message----- > From: osei the dude > Hello, I have 9 SAS programs, all within the same Windows > folder that I > usually run at the same time - one right after the other. For > convenience, is it possible to write a simple SAS program > that will let > me run ...

Re: SAS Advanced Programming Exam for SAS 9: SAS Joke of the year. #7
Well Toby, let me ask something then. Since I am not an ODS fan and haven't used proc report/tabulate for some time, would that be an automatic disqualifier since you don't allow reference books or materials? SAS does not provide tools that help me code ODS (except for EG) and therefore a reference material is all I would need. Now, it's not like I haven't used proc report (used it extensively at one time), it's just that I prefer other means to produce the final output. It seems that a test like this would toss me out of the pool from the get-go. Heck, maybe that's what the goal would be ;-] Alan Alan Churchill Savian www.savian.net -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of toby dunn Sent: Tuesday, September 04, 2007 3:34 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: SAS Advanced Programming Exam for SAS 9: SAS Joke of the year. Good deal Bob, atleast that company was headed in the right direction IMO... I have given such tests and taken them. I ussually give them a data set, the specs I want them to follow, and a example of what I want the output to look like. Then I tend to give them like 4 or 5 hours if they need it to complete the project. In reallity they should be done in an hour or so. The test should be challenging but not too challenging, and the solution should involve a few data steps, procedures, and some type of reporting..... Toby Dunn Comprimise is like telling a lie, it...

Re: Running a SAS program within a SAS program
%include() On Mon, Apr 21, 2008 at 12:55 PM, Kathleen Santos <flowerpotcat@gmail.com> wrote: > Hello, > > I would like to combine multi years of data into one. Each year has a > particular data set and a particular program to create a SAS dataset. > However, not all programs are the same (e.g. variable names may change > throughout the years). > > What I would like to do is to create one program that would call on the > other programs to create SAS datasets. Then I'll integrate them together and > do whatever I it is I need to do. > > I hope someone can help me. > > Thanks. > > Kathleen > -- =============================== WenSui Liu ChoicePoint Precision Marketing Phone: 678-893-9457 Email : wensui.liu@choicepoint.com Blog : statcompute.spaces.live.com =============================== ...

Re: Running SAS programs from within a SAS program
Keith, You can use a series of %include statements naming the programs in the order you want to call them in. %include "drive:\your_folder\program name.txt" ; Mah-J M. Soobader, PhD Principal consultant STATWORKS www.statworks.com -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of Keith W. Larson Sent: Friday, November 18, 2005 10:32 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Running SAS programs from within a SAS program Dear All, I have several small(ish) SAS programs that convert and format DBF files. Thanks to all who helped solve formatting problems. I would like to create a master SAS program that calls each one in sequence. Any ideas? Cheers, Keith __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com ...

Re: Running a SAS program within a SAS program #2
Kathleen Based on your subject, my immediate impulse was %inlude() where you put a fileref in the quotes. However, I think you want to do something else. You say that you have individual programs that produce a set for each year. Do you store these sets somewhere or do you run the programs when you want data for a given year. I would suggest that you first get a collection of these yearly sets and run a contents on each one. Then, write a program similar to Data mylib.combined; set mylib.year1(rename = (Dates = Date ....)) mylib.year2(rename= (Sdates=Date....)) ..... ; The idea would be to get rid of the variations in the variable names. You could simply copy in the individual programs into one honking big program and keep running this until you get a uniform combined set but you will use a lot of machine cycles doing this. Assuming that you have to make several passes at the data in order to get things right, I would work from stored data sets where all you are doing is changing the rename statements. Good luck Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977 Kathleen Santos <flowerpotcat@GMA IL.COM> To Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU Discussion" cc <SAS-...

Re: Running a SAS program within a SAS program #3
Kathleen, You can use %INCLUDE in a SAS program to call other SAS programs. Jack Clark Research Analyst Center for Health Program Development and Management University of Maryland, Baltimore County -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Kathleen Santos Sent: Monday, April 21, 2008 12:55 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Running a SAS program within a SAS program Hello, I would like to combine multi years of data into one. Each year has a particular data set and a particular program to create a SAS dataset. However, not all programs are the same (e.g. variable names may change throughout the years). What I would like to do is to create one program that would call on the other programs to create SAS datasets. Then I'll integrate them together and do whatever I it is I need to do. I hope someone can help me. Thanks. Kathleen ...

Re: Running SAS programs from within a SAS program #2
Or better when programs are in one directory file code "drive:\your_folder\" ; %inc code ( prog1 prog2 prog3 ... ) ; Then the next step is parameter driven macros in an autocall library. %prog1(parm1=...) %prog2(alpha=...) ..... Ian Whitlock ================= Date: Fri, 18 Nov 2005 22:54:54 -0500 Reply-To: mah-j@statworks.com Sender: "SAS(r) Discussion" From: "mah-j@statworks.com" <msoobader@VERIZON.NET> Subject: Re: Running SAS programs from within a SAS program Comments: To: "Keith W. Larson" <keith_w_larson@YAHOO.COM> In-Reply-To: <20051119033140.88868.qmail@web51405.mail.yahoo.com> Content-type: text/plain; charset=iso-8859-1 Keith, You can use a series of %include statements naming the programs in the order you want to call them in. %include "drive:\your_folder\program name.txt" ; Mah-J M. Soobader, PhD Principal consultant STATWORKS www.statworks.com -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L]On Behalf Of Keith W. Larson Sent: Friday, November 18, 2005 10:32 PM To: SAS-L Subject: Running SAS programs from within a SAS program Dear All, I have several small(ish) SAS programs that convert and format DBF files. Thanks to all who helped solve formatting problems. I would like to create a master SAS program that calls each one in sequence. Any ideas? Cheers, Keith ______________________...

Re: Launching a SAS-AF program from another SAS-AF.
Try it with call display: call display('methdlib.validate.amount.scl',amount,error); (example from the SAS docu) Gerhard On Fri, 31 Oct 2008 05:27:13 -0400, Miguel Alvarez <migalvher@YAHOO.ES> wrote: >Hi everybody. > >I've three different SAS-AF applications. The three of them have the same >users. >I'm developing another application who executes the other three with the >same login. Kind of an application manager. > >My first try was to call a .bat file with this: > >start "reinit" "%SAS%\sas.exe" -config "%APPL%\SASV9.CFG" -autoexec >"%APPL%\autoexec.sas" > >The problem is, it opens a new SAS session every time i launch one of them. >Every application has its own autoexec and config file so them execute in >every launch. > >Is there any way to do this keeping a first and unique session?, so I can >keep the main frame?(main menu or launcher frame). > >Thanx! ...

Re: SAS Advanced Programming Exam for SAS 9: SAS Joke of the year.
I took the advanced exam this April because I wanted a relatively systematic way of assessing my knowledge of SAS in a short time span. For that purpose, it was worth it. Since I learn SAS by doing new tasks, or re-doing old tasks in a new way, I assume my knowledge of SAS is uneven, even though I am regarded as productive, and frequently creative in using SAS to solve our group's problems. I passed the test, with lower subscores on the components that I expected to be weakest on. I thought many of the questions made me think about some fundamental, sometimes subtle, features of the language. I did some guessing, but that was on my weaker topics. So the exam results, in my view, reflected something real. I agree, a prospective employer should not put much stock in SAS certification exams. Many highly effective people are not good test takers. Besides, this exam is a crude instrument. My score was identical to a colleague who still regularly asks me for guidance in finding solutions in SAS to specific problems. I probably know more SAS than he does (and he is a good SAS programmer), but you wouldn't know from the exam results. As to version 9-specific questions, I don't recall whether there was much material that was version 9 only. But I expected the test to be more oriented to "advanced" concepts than to new features of version 9. By the way, even though I passed, I can't get a SAS advanced certificate -- because I haven't taken the...

Running SAS programs from within a SAS program
Dear All, I have several small(ish) SAS programs that convert and format DBF files. Thanks to all who helped solve formatting problems. I would like to create a master SAS program that calls each one in sequence. Any ideas? Cheers, Keith __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com Keith, You can use a series of %include statements naming the programs in the order you want to call them in. %include "drive:\your_folder\program name.txt" ; Mah-J M. Soobader, PhD Principal consultant STATWORKS www.s...

Running a SAS program within a SAS program
Hello, I would like to combine multi years of data into one. Each year has a particular data set and a particular program to create a SAS dataset. However, not all programs are the same (e.g. variable names may change throughout the years). What I would like to do is to create one program that would call on the other programs to create SAS datasets. Then I'll integrate them together and do whatever I it is I need to do. I hope someone can help me. Thanks. Kathleen ...

Re: SAS Advanced Programming Exam for SAS 9: SAS Joke of the year. #2
jontugman, Test preparation is akin to following a simple algorithm: 1. Evaluate the test and discover if it is worth taking. 2. If #1 evaluates false then go to exit. 3. Determine if your *test* knowledge of SAS is insufficient. 4. If #3 evaluates true, do the test preparation. 5. Pay the money. 6. Take the test. 7 Exit. From your standpoint, the step of paramount importance is step #1. That is where you mainly failed. From SAS' standpoint, only one step matters: #5. This is the only reason the test was created in the first place. The world would be a better place if all employers understood that as well. However, some recruiters/HRers require the certificate as a CYA backup should they accidentally hire a pure test-passer. Fortunately, I have not seen many occurrences of this nature since the inception of the boondoggle, perhaps because most candidates are almost inevitably interviewed by people qualified in SAS better than HR. And most qualified people saw the program for what it is even before its advent. SAS-L is replete with numerous posts to prove it. Needless to say, it does not imply in any way that any certificate-holder has no more SAS behind the belt than the certificate can cover. Far from that! Many fantastic real-world people have been forced into the thing by their SAS partnership business needs, many have taken it just for the heck of it because their employer would pay for it, etc. My opposition to the thing as a matter of principle is based on t...

Re: SAS Advanced Programming Exam for SAS 9: SAS Joke of the year. #5
Good deal Bob, atleast that company was headed in the right direction IMO... I have given such tests and taken them. I ussually give them a data set, the specs I want them to follow, and a example of what I want the output to look like. Then I tend to give them like 4 or 5 hours if they need it to complete the project. In reallity they should be done in an hour or so. The test should be challenging but not too challenging, and the solution should involve a few data steps, procedures, and some type of reporting..... Toby Dunn Comprimise is like telling a lie, it gets easier and easier. Each comprimise you make, that becomes your standard. Perfection doesnt exist, once you reach it, its not perfect anymore. It means something else. From: Bob_Abelson@HGSI.COM Reply-To: Bob_Abelson@HGSI.COM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: SAS Advanced Programming Exam for SAS 9: SAS Joke of the year. Date: Tue, 4 Sep 2007 17:22:59 -0400 I interviewed at a company that gave a test where I had a half hour to produce a very simple report using PROC REPORT. I was provided all the manuals I wanted, but because I had used PROC REPORT before, I wanted none of them. I finished in five minutes, and most people on SAS-L would be able to beat that time. Bob Abelson HGSI 240 314 4400 x1374 bob_abelson@hgsi.com "toby dunn" <tobydunn@HOTMAIL.COM> Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> 09/04/2007 05:15 PM Please respond to "toby d...

Web resources about - Re: Reusing code from SAS Program in another SAS Program #7 1547527 - comp.soft-sys.sas

Wikipedia:Reusing Wikipedia content - Wikipedia, the free encyclopedia
There are many reusers of Wikipedia's content, and more are welcome. If you want to use Wikipedia's text materials in your own books/articles/web ...

Andrea Reusing (@andreareusing) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

YouTube - Reusing Soda Can Tabs Closet Organizer Double Hanger
You are using an outdated browser, which YouTube no longer supports. Since some features on YouTube may not work, you are viewing a lightweight ...

The grey area of freelancers reusing their own work
Write more for less pay. In the content-hungry online media industry, there is a temptation for freelancers to reuse their own writing, research ...

Stop Reusing Your Old Exams, You LAZY Law School Professors!
How hard is it to write an exam for a course you've taught all semester? On a scale of one to ten ten involving programing a rocket ship, one ...

Reusing Baby Food Jars
Reusing glass baby food jars isn't a new idea. The chubby pots make for great containers for all manner of items - craft and sewing supplies, ...

Daimler is reusing electric vehicle batteries to store renewable energy
The company says its stationary storage unit will come online in early 2016.

Rod Stewart Sued for Reusing Image of the Back of His Head
Celebrity photographer Bonnie Schiffman has filed a copyright lawsuit that claims

Three infections linked to Colorado dentist accused or reusing needles for over 11 years
... practice (CBS News) Three possible infections have been linked to embattled Colorado oral surgeon Dr. Stephen Stein, the man accused of reusing ...

Movie Studios Sued For Reusing Lesser Known Parts Of Famous Soundtracks
It’s going to be tough to prove. But if it goes through, this could lead to changes to the way that music is made – and used – in our movies ...

Resources last updated: 3/18/2016 8:19:51 PM